[Support request] Taxonomy Archive Total on Custom Post type

Home Forums Support Taxonomy Archive Total on Custom Post type

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #335970
    Paul

    I’ve worked out how to change the Archive Title using this code:

    if ( ! function_exists( ‘generate_archive_title’ ) ) :
    /**
    * Build the archive title
    *
    * @since 1.3.24
    */
    add_action( ‘generate_archive_title’,’generate_archive_title’ );
    function generate_archive_title()
    {
    ?>
    <header class=”page-header<?php if ( is_author() ) echo ‘ clearfix’;?>”>
    <?php do_action( ‘generate_before_archive_title’ ); ?>
    <h1 class=”page-title”>
    <?php
    if ( is_category() ) :
    single_cat_title();

    elseif ( is_tag() ) :
    single_tag_title();

    elseif ( is_author() ) :
    /* Queue the first post, that way we know
    * what author we’re dealing with (if that is the case).
    */
    the_post();
    echo get_avatar( get_the_author_meta( ‘ID’ ), 75 );
    printf( ‘<span class=”vcard”>’ . get_the_author() . ‘</span>’ );
    /* Since we called the_post() above, we need to
    * rewind the loop back to the beginning that way
    * we can run the loop properly, in full.
    */
    rewind_posts();

    elseif ( is_day() ) :
    printf( __( ‘Day: %s’, ‘generatepress’ ), ‘<span>’ . get_the_date() . ‘</span>’ );

    elseif ( is_month() ) :
    printf( __( ‘Month: %s’, ‘generatepress’ ), ‘<span>’ . get_the_date( ‘F Y’ ) . ‘</span>’ );

    elseif ( is_year() ) :
    printf( __( ‘Year: %s’, ‘generatepress’ ), ‘<span>’ . get_the_date( ‘Y’ ) . ‘</span>’ );

    elseif ( is_tax( ‘post_format’, ‘post-format-aside’ ) ) :
    _e( ‘Asides’, ‘generatepress’ );

    elseif ( is_tax( ‘post_format’, ‘post-format-image’ ) ) :
    _e( ‘Images’, ‘generatepress’);

    elseif ( is_tax( ‘post_format’, ‘post-format-video’ ) ) :
    _e( ‘Videos’, ‘generatepress’ );

    elseif ( is_tax( ‘post_format’, ‘post-format-quote’ ) ) :
    _e( ‘Quotes’, ‘generatepress’ );

    elseif ( is_tax( ‘post_format’, ‘post-format-link’ ) ) :
    _e( ‘Links’, ‘generatepress’ );

    elseif ( is_post_type_archive( ‘review’ ) ) :
    _e( ‘Emotion Academy Reviews’, ‘generatepress’ );

    else :
    _e( ‘Archives’, ‘generatepress’ );

    endif;
    ?>
    </h1>
    <?php do_action( ‘generate_after_archive_title’ ); ?>
    <?php
    // Show an optional term description.
    $term_description = term_description();
    if ( ! empty( $term_description ) ) :
    printf( ‘

    %s

    ‘, $term_description );
    endif;

    if ( get_the_author_meta(‘description’) && is_author() ) : // If a user has filled out their decscription show a bio on their entries
    echo ‘

    ‘ . get_the_author_meta(‘description’) . ‘

    ‘;
    endif;
    ?>
    <?php do_action( ‘generate_after_archive_description’ ); ?>
    </header><!– .page-header –>
    <?php
    }
    endif;

    What I’m trying to work out is how to change the archive title for Taxonomies:

    https://www.emotionacademy.com.au/review/adelaide/

    1.) Can this be done automatically so that it automatically uses the Taxonomy Name in the Taxonomy Archive Title. e.g. “Reviews” Adelaide

    2.) If not how would u do it?

    Thanks heaps

    Paul

    #336028
    Tom
    Lead Developer
    Lead Developer

    GP actually uses the_archive_title() now which is a core WP function: https://developer.wordpress.org/reference/functions/get_the_archive_title/

    It should display the taxonomy title by default.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.