[TUTORIAL] Adding Pagination Elements for SEO on Cats and Tags

Posted in: Newspaper
Post count: 9544

Hi,
for many of us, we like to differentiate the ‘on page’ h1 and h2 elements for subsequent category and tag pages, which we do have indexed for large complex news portals.

However “most” commercial themes, don’t add numeration, and so on pages 1,2,3 of an archive for Book News, all pages end up with Book News as the h1 tag, regardless of page number. While Yoast SEO, or All-in-One SEO, or similar can add elements to address this in meta data, which protects from major issues with Google and SERPS, and canonical links; it doesn’t help each page ‘stand on its own’ as much for the static elements.

The fix I did to our sites was adding this inside the h1 tags, and in the description blocks on our sites.
<?php if ( $paged < 2 ) { } else { echo (' - Page '); echo ($paged);}
?>

or
<h1 class="entry-title td-page-title">
<?php /*" rel="bookmark" title="<?php echo __td('Posts in ') . $current_tag_name?>">Tag: <?php echo $current_tag_name ?>*/?>
<span><?php echo __td('Tag');?>: <?php echo $current_tag_name ?>
<?php if ( $paged < 2 ) { } else { echo (' - Page '); echo ($paged);}?>
</span>
</h1>

Post count: 9544

If you want you can also get tricky and add additional elements, like “News”…

so, if your tag was Toyota Trucks

do this:
<?php echo $current_tag_name ?> News

And you’d get
Toyota Trucks News – Page 2

Post count: 9544

Little trickier with the ‘categories’ due to
a) being in sub folder for the header element so it can be changed by different style/layouts, and
b) funky if/then on the category description makes it hard to do that properly.

For example on my copy of Newsmag, the actual piece is in /parts/page-category-header.php

and this bit is tough to modify unless you play with it

<header>
<h1 class="entry-title td-page-title">
<span><?php echo $cur_cat_obj->name ?> <?php if ( $paged < 2 ) { } else { echo (' - Page '); echo ($paged);}?></span>
</h1>
</header>

<?php
//breadcrumb
echo td_page_generator::get_category_breadcrumbs($cur_cat_obj);

//the category description
if (!empty($cur_cat_obj->description)) {
echo '<div class="td-category-description">';
echo $cur_cat_obj->description;
echo '</div>';
}
?>

Post count: 9544

Might be easier to hack in normal WP description in template:
https://developer.wordpress.org/reference/functions/category_description/

<div>
<?php single_cat_title( __( 'Currently browsing', 'textdomain' ) ); ?>:
<?php echo category_description(); ?>
</div>

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