Tagged: 

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

    Hi guys,

    I am getting errors in search console as Google thinks that the paginated posts are different pages and not one and the same.

    I saw this code from Ismael on another post but I see the word “page/” in them and that wouldn’t apply here. We need to add this hook to any paginated page/post (in my case, it’s posts as I don’t see the Tag pages being automatically paginated)

    Here’s a post example: https://bodasyweddings.com/choosing-a-wedding-bouquet-how-pick-bridal-flowers/ and any pagination shows as https://bodasyweddings.com/choosing-a-wedding-bouquet-how-pick-bridal-flowers/2/ (etc… if you break it into more pieces)

    This was Ismael code:

    add_action(‘wp_head’, ‘wp_head_pagination_mod’);
    function wp_head_pagination_mod() {
    $page = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : get_query_var( ‘page’ );

    if( ! $page ) return;

    $url = (isset($_SERVER[‘HTTPS’]) ? “https” : “http”) . “://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”;
    $url = substr($url, 0, strpos($url, “page”));

    $link_prev = $url . ‘page/’ . ($page – 1);
    $link_next = $url . ‘page/’ . ($page + 1);

    $output = ‘ <link rel=”prev” href=”‘. $link_prev .'” />’ . PHP_EOL;
    $output .= ‘ <link rel=”next” href=”‘. $link_next .'” />’ . PHP_EOL;
    echo $output;
    }

    Here’s Yoast’s article: https://kb.yoast.com/kb/is-the-plugin-compatible-with-paginated-content/

    And I’d rather not change my current URLs as I have links pointing at them. I like not having the word /page/ in the url.

    Help, suggestions, anything… all welcome!

    Thank you!!!

    Warmly,

    Havi

    #942898

    Hey havi,

    Thank you for using Enfold.

    Replace that part of the code with this.

    $link_prev = $url . ($page – 1);
    $link_next = $url . ($page + 1);
    

    Best regards,
    Ismael

    #942929

    Hi Ismael!!

    Thank you!!! :)

    I just received an email from Yoast that the original issue was their bug and they will fix it. The original problem was that the /2/ etc pages were not being included in their sitemap. I guess their first reply was not valid and they’ll hopefully fix it soon.

    Warmly,

    Havi

    #943438

    Hi,

    Thank you for the info. Let us know if you need anything else. :)

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Paginated posts not Showing res NEXT and PREV’ is closed to new replies.