How to set Taxonomy Title and Description to appear only on the first page in Genesis

Posted on

In GenesisWP Facebook group a user asked:

I have been googling for a couple of days and checked the forums, but no help that I could find. I have a question. Is it possible to add a shortcode to make the Archive Intro Text appear only on the first page of the category archive?

Title and Description (if set) for category, tag or taxonomy term archives in Genesis appear on all the paginated pages by default.

The function that displays these is genesis_do_taxonomy_title_description and it is hooked to genesis_before_loop. We can go one level up (hook as late as you can) in the actions hierarchy to genesis_before_content, do a check for paginated pages and remove the taxonomy title and description on them so it appears only on the first page.

Add the following in child theme’s functions.php:

add_action( 'genesis_before_content', 'sk_taxonomy_title_description' );
/**
 * Remove Taxonomy Title and Description on paginated pages.
 */
function sk_taxonomy_title_description() {
    global $wp_query;

    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

    // if we are on the first page of pagination, abort.
    if ( 1 == $paged )  {
        return;
    }

    remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
}

Reference: genesis/lib/structure/archive.php