[Resolved] Duplicate H1 Tages

Home Forums Support [Resolved] Duplicate H1 Tages

Home Forums Support Duplicate H1 Tages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1515349
    David

    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

    #1516040
    David
    Staff
    Customer Support

    Hi there,

    how are you adding the title to the Blog Page ?

    #1516720
    David

    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

    #1517258
    David
    Staff
    Customer Support

    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>';
    }
    ?>
    #1517283
    David

    Thank you so much, that has worked perfectly.

    Best Regards,
    David

    #1517395
    David
    Staff
    Customer Support

    Glad to hear that !

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