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

    I implemented fixes from a previous thread https://kriesi.at/support/topic/problem-about-rel-next-previous-in-pagination/

    and it ALMOST works but my resulting rel=”next” and rel=”prev” href= excludes the “h” in https:// address as well as adds a “p” to page/#

    I only require this solution for the Blog Pages (multiple pages need to be indexed). My Yoast plugin works great for any archived blog posts (in categories) but not for the main blog page posts.

    Please help! I am almost there!

    #1405895

    This is the code I need to debug:
    add_action(‘wp_head’, ‘wp_head_pagination_mod’);
    function wp_head_pagination_mod() {
    global $wp_query;

    $page = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : get_query_var( ‘page’ );
    $page = ! $page ? 0 : $page;

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

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

    if( ! $page ) {
    $output .= ‘ <link rel=”next” href=”‘. $link_next .'” />’ . PHP_EOL;
    } elseif( $page == $wp_query->max_num_pages ) {
    $output = ‘ <link rel=”prev” href=”‘. $link_prev .'” />’ . PHP_EOL;
    } else {
    $output = ‘ <link rel=”prev” href=”‘. $link_prev .'” />’ . PHP_EOL;
    $output .= ‘ <link rel=”next” href=”‘. $link_next .'” />’ . PHP_EOL;
    }

    echo $output;
    }

    It is resulting in <link rel=”next” href=”ttps://mylinkhere/blog/ppage/3″ />
    How can I get it to show https and take out the extra “p” in pages?


    @ISMAEL
    are you available to assist?

    #1405906

    Hi,

    Thank you for the inquiry.

    We may need to inspect the site in order to understand the issue better. Please provide the site details in the private field.

    If you need a quick fix, please look for this code in the previous filter.

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

    Replace it with:

    $link_prev = str_replace("ppage", "page", $link_prev);
    $link_next = str_replace("ppage", "page", $link_next);
    

    Best regards,
    Ismael

    #1405947
    This reply has been marked as private.
    #1405949

    This didn’t work. It works for all but first and last pages when I put:

    $url = (isset($_SERVER[‘HTTPS’]) ? “hhttps” : “http”) . “://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”;

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

    if( ! $page ) {
    $output .= ‘ <link rel=”next” href=”‘. $link_next .'” />’ . PHP_EOL;
    } elseif( $page == $wp_query->max_num_pages ) {
    $output = ‘ <link rel=”prev” href=”‘. $link_prev .'” />’ . PHP_EOL;
    } else {
    $output = ‘ <link rel=”prev” href=”‘. $link_prev .'” />’ . PHP_EOL;
    $output .= ‘ <link rel=”next” href=”‘. $link_next .'” />’ . PHP_EOL;
    }

    echo $output;
    }

    #1406052

    Hi,
    Thanks for the link to your site, I see that you are using Enfold v4.7.5 with WordPress v6.1.1 and PHP v8.1.18
    Enfold v4.7.5 is not PHP v8+ or WP 6+ ready, please update to Enfold v5.5
    Before updating please remove the header.php from your child theme as it will most likely cause issues, we don’t recommend adding header.php or footer.php to child themes anymore as this is the top reason for crashes when updating.

    Best regards,
    Mike

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