admin管理员组

文章数量:1323714

I am stuck having to use an older plugin, which is no longer maintained. The problem i'm facing is that in WordPress 5.5, the pagination that plugin uses, breaks. All you see is the first page.

This is the code for pagination it uses:

<?php

if ($data['total_pages'] > 1)
{
    $add_args = $data['search'];
    unset($add_args['paged’]);
    
    echo '<p class="parariusoffice-pagination">' . 
        paginate_links(array(
            'total' => $data['total_pages'],
            'current' => $data['paged’],
        
            // maybe include this: get_option('permalink_structure')
            'base' => rtrim(get_page_link(get_the_ID()), '/') . '/%#%/',
            'add_args' => $add_args
        )) .
        '</p>';
}

?>

<?php endif; ?>

I have found that changing the permalink structure in the WordPress settings has no effect on this error.

I found this information on permalinks: / , but I am unable to make it work.

How can I make pagination work in this plugin?

Edit: I have found that the main cause is that WordPress no longer allows paginated urls like: /aanbod-panden/2/?order=online_date%3Ddesc It was suggested here: to change the numeric values at the end of the url /aanbod-panden/2/ to /aanbod-panden/?2/

Any suggestions on how to accomplish that in the above plugin code are more than welcome!

I am stuck having to use an older plugin, which is no longer maintained. The problem i'm facing is that in WordPress 5.5, the pagination that plugin uses, breaks. All you see is the first page.

This is the code for pagination it uses:

<?php

if ($data['total_pages'] > 1)
{
    $add_args = $data['search'];
    unset($add_args['paged’]);
    
    echo '<p class="parariusoffice-pagination">' . 
        paginate_links(array(
            'total' => $data['total_pages'],
            'current' => $data['paged’],
        
            // maybe include this: get_option('permalink_structure')
            'base' => rtrim(get_page_link(get_the_ID()), '/') . '/%#%/',
            'add_args' => $add_args
        )) .
        '</p>';
}

?>

<?php endif; ?>

I have found that changing the permalink structure in the WordPress settings has no effect on this error.

I found this information on permalinks: https://developer.wordpress/reference/functions/paginate_links/ , but I am unable to make it work.

How can I make pagination work in this plugin?

Edit: I have found that the main cause is that WordPress no longer allows paginated urls like: /aanbod-panden/2/?order=online_date%3Ddesc It was suggested here: https://core.trac.wordpress/ticket/51001 to change the numeric values at the end of the url /aanbod-panden/2/ to /aanbod-panden/?2/

Any suggestions on how to accomplish that in the above plugin code are more than welcome!

Share Improve this question edited Aug 28, 2020 at 9:07 ErwinV asked Aug 24, 2020 at 10:31 ErwinVErwinV 213 bronze badges 3
  • Do you mean you don't see any pagination links, or they don't work? Where does $data['total_pages'] come from? I don't think WordPress sets it, even before 5.5. – Rup Commented Aug 24, 2020 at 10:42
  • The navigation links do appear, but clicking them has no effect. They only show the first page. I found this: searchenginejournal/wordpress-5-5-issues/377851/#close which perfectly describes it. My page is: /aanbod-panden/ , when clicking page 2 in the pagination the url should become aanbod-panden/2/?order=online_date%3Ddesc but that gets redirected to the first page. The $data['total_pages'] comes from the plugin, that pulls real estate data from a database. – ErwinV Commented Aug 24, 2020 at 12:39
  • The puzzle continues. I have modified above code to: 'base' => rtrim(get_page_link(get_the_ID()), '/') . ‘?paged=%#%‘, Which does provide the pagination in the urls, however does not show the actual paginated pages. When I disable the redirect_canonical() function, the paginated pages return a 404 error. – ErwinV Commented Sep 7, 2020 at 11:19
Add a comment  | 

1 Answer 1

Reset to default 1

I finally found a solution.

Disable the redirect canonical function with:

add_filter( 'redirect_canonical', '__return_false' );

And fix the 404 error that results from disabling the redirect canonical with this suggestion

本文标签: Wordpress 55 breaks pagination in an older plugin