[Resolved] different h1 tags for category pages

Home Forums Support [Resolved] different h1 tags for category pages

Home Forums Support different h1 tags for category pages

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1111862
    anand

    in the category pages or blog archive pages… the h1 title appears the same … even though the page title shows the page number + category name (using rank math plugin)

    how to show the h1 title as “category name + page number of total pages” in those blog arhive pages

    this helps with ahrefs.com seo score

    #1112112
    David
    Staff
    Customer Support

    Hi there,

    try this PHP snippet:

    add_filter( 'get_the_archive_title', function ( $title ) {
    
        $paged_maxnum = $GLOBALS['wp_query']->max_num_pages;
    
        if ( $paged_maxnum > 1 ) {
    
            $paged_current_page = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
    
            $title_postfix = ' ' . $paged_current_page . ' of ' . $paged_maxnum;
    
            $title .=  $title_postfix;
    
        }
    
        return $title;
    
    }, 50);
    #1112210
    anand

    Thanks for the Answer…
    I added the following it works fine

    add_filter( 'get_the_archive_title', function ( $title ) {
    
        $paged_maxnum = $GLOBALS['wp_query']->max_num_pages;
    
        if ( $paged_maxnum > 1 ) {
    
            $paged_current_page = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
    
            $title_postfix = ' - Page ' . $paged_current_page . ' of ' . $paged_maxnum;
    
            $title .=  $title_postfix;
    
        }
    
        return $title;
    
    #1112213
    David
    Staff
    Customer Support

    Glad to be of help

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