Pagination URL

#591419
  • Resolved Anonymous
    Rank Math free

    I use WP Grid Builder and the pagination pages that are created look like this:

    example.com/blog/?_page=

    Rankmath automatically creates pagination pages that look like this:

    /blog/page/2/
    /blog/page/3/

    etc.

    This information is added in the head of the page.

    Either the information needs to be removed or I need to be able to customize it.
    How does this work?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello,

    Thank you for your query. We will be super-happy to help you with your concern.

    The pagination pages that you see are: /blog/page/2/
    Those pages are default within WordPress, that is how WordPress handles pagination without Rank Math.

    I am not fully sure what you are asking but I assume you wish to change the word ‘page’ inside of the /page/2/ pagination structure to something else.

    To change the default pagination in WordPress try this: https://wordpress.org/support/topic/feature-request-edit-pagination-slug/

    I would, however, recommend that you rather change the pagination of your WP Grid Builder plugin, and try consulting with your WP Grid Builder developers on how that is done.

    If you are not referring to the word, can you please confirm if you wish to change the canonical URL?

    Please share the affected URL in the sensitive data section so we could check it further.

    Looking forward to helping you.

    Anonymous
    Rank Math free

    Hello,
    unfortunately you have misunderstood my question.

    1) I have already spoken with the wpgridbuilder developers. The pagination is not to change.

    2.) The pagination /page/2/ etc. only appears when I activate rankmath.

    3.) In the rankmath settings I can only set that the paginated pages should be on noindex. I do not want that. I would like to remove the /page/2/ etc. either completely or (the better option) would be to adjust the pagination as I have described. /page/2/ => /?_page=2

    Anonymous
    Rank Math free

    Unfortunately, the snippet does not work.

    // Translate “page” slug into pagination
    function my_custom_page_word() {
    global $wp_rewrite;
    $wp_rewrite->pagination_base = ‘?_page=’;
    }
    add_action( ‘init’, ‘my_custom_page_word’ );

    It only replaces “page”. Not the slash at the end.
    So my result is: <link rel=”next” href=”/blog/?_page=/2/” />

    But it should be: <link rel=”next” href=”/blog/?_page=2″ />

    Hello,

    I apologize for the confusion. In this case, please refer to this code:

    add_filter( "rank_math/frontend/next_rel_link", function( $link ) {
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	
    	if(is_paged()){
    		$link = '<link rel="next" href="/blog/?_page=' . $paged + 1 .'" />';
    	}
    	return $link;
    });
    
    add_filter( "rank_math/frontend/prev_rel_link", function( $link ) {
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	
    	if(is_paged()){
    		$link = '<link rel="prev" href="/blog/?_page=' . $paged - 1 .'" />';
    	}
    	return $link;
    });

    That should allow you to modify the adjacent links as per your requirements.

    Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.

    Anonymous
    Rank Math free

    Thank you very much. But the code works only for /blog/. Of course, I have many other pages that also have the problem. Is there a general solution that works not only for /blog/?

    Hello,

    You can try this updated filters which should work whether you are in the blog pagination or any other paginated pages on your website:

    
    add_filter( "rank_math/frontend/next_rel_link", function( $link ) {
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	if( is_paged() ) {
    		$link = '<link rel="prev" href="' . esc_url( remove_query_arg( 'paged' ) ) . '?_page=' . ( $paged + 1 ) .'" />';
    	}
    	return $link;
    });
    
    add_filter( "rank_math/frontend/prev_rel_link", function( $link ) {
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	if( is_paged() ) {
    		$link = '<link rel="prev" href="' . esc_url( remove_query_arg( 'paged' ) ) . '?_page=' . ( $paged - 1 ) .'" />';
    	}
    	return $link;
    });
    

    Hope this helps solve your issues.

    Don’t hesitate to get in touch if you have any other questions.

    Anonymous
    Rank Math free

    Sorry, I do not understand. There is nothing at all about

    ?_page=

    Hello,

    After adding the filter on the website, the prev and rel links didn’t change at all? Is that the current issue you are facing?

    If that’s the case please share the website where this is happening in the sensitive data section so we can see the output of this and advise on what could possibly be changed in the filter.

    It’s almost impossible to create an accurate code without seeing the actual output of the current filter because we cannot debug what’s happening inside the code.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)

The ticket ‘Pagination URL’ is closed to new replies.