Site logo

Archived topic

Duplicate H1 Tages

5 replies · Started by David on November 2, 2020

Viewing posts 1–6 of 6

Hi, I would like to eliminate duplicate h1 tag issues by adding page numbers to the blog archive of my website from pages 2 onwards.

https://darkstories.com.au/blog/
https://darkstories.com.au/blog/page/2/
https://darkstories.com.au/blog/page/3/
https://darkstories.com.au/blog/page/4/
https://darkstories.com.au/blog/page/5/

The below is the code in use to correctly tag the title as H1 as per the recommended approach.

<?php if ( is_home() ) : ?>
<h1 class="main-title" itemprop="headline">Dark Stories True Crime Blog</h1>
<?php else : ?>
<p class="main-title" itemprop="headline">Dark Stories True Crime Blog</p>
<?php endif; ?>

Would you be able advise if it is possible to add page numbers to the title from pages 2 onwards please?

Best Regards
David

Hi there,

how are you adding the title to the Blog Page ?

Hi David,

Via the addition of an element Hook (after main content), displayed on the blog page only, with Execute PHP ticked:-

<?php if ( is_home() ) : ?>
<h1 class="main-title" itemprop="headline">Dark Stories True Crime Blog</h1>
<?php else : ?>
<p class="main-title" itemprop="headline">Dark Stories True Crime Blog</p>
<?php endif; ?>

Regards
David

Try this instead:

<?php 
if ( is_paged() ) {
    // If paginated page output title with current page
    $current_page = max(1, get_query_var('paged'));
    echo '<p class=”main-title” itemprop=”headline”>Dark Stories True Crime Blog - Page ' . $current_page .  '</p>';
  
} else {
    echo '<h1 class=”main-title” itemprop=”headline”>Dark Stories True Crime Blog</h1>';
}
?>

Thank you so much, that has worked perfectly.

Best Regards,
David

Glad to hear that !

This archived topic is closed to new replies.