Url:param key posts per page not working

HI,

I had a ticket on this last week. All was working, and now it is not. We have not altered anything, and the client “says” they did not.

We have a page: The page is here: https://madeinclt.org/artist-directory/?posts_per_page=5 with a drop-down to change the number of results. We are using the following, and as I mentioned, it was working, so now we are perplexed.

{{dc:url:param key=“posts_per_page” fallback=“10”}}

Thank you for any guidance.

Hi Michael,

Thanks for reaching out.
I have checked the page and found that it is a working file while changing the number of results from dropdown. If you are still facing the same issue, please check once by clearing all types of cache including the System Cache from Cornerstone > Settings > System > Clear System Cache and check in the incognito/private mode of the browser.

Thanks

Thank you, just did that. It seems to only work for values of 5 and 10 and the pagination does not update.

Oddly it does seem to work in a taxonomy but not the main page.https://madeinclt.org/artist-type/craft/visual-arts/?

Hi Michael,

I checked it last time and it was working as expected. Now it is not working, can you please check if the query has been overridden through any custom coding or not? You can check that by activating the parent theme and deactivating the plugins.
If that does not help, please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– WordPress Admin username/password

To create a secure note, click the key icon underneath any of your posts.

Thanks

Added. THANK YOU!!!

Hi Michael,

It seems that some custom coding is overriding the default WordPress query to change the posts_per_page. I would suggest you check the code if there is anything specified for this specific post type.
Please remember that we don’t offer any support or investigation on custom coding.

Thanks

Thank you, for the follow-up. We do not have any custom code. Can you let me know how you discovered that so we can dig deeper?

The pagination and per page work fine when a taxonomy is selected. This seems to have happened with the latest Pro/Cornerstone upgrade.

Sorry, for all the queries, just a tad concerned how it worked and then stopped working.

We did find a workaround for now. Thank you!

Hello Michael,

You are running this code in your child theme’s functions.php file:

add_action( 'pre_get_posts', 'new_sort_order',102); 
    function new_sort_order($query) {
    if(is_archive() && is_post_type_archive( "artist" )):
    $query->set( 'orderby', 'title' );
    $query->set( 'order', 'ASC' );
    endif;    
    };

add_action( 'pre_get_posts', 'alpha_order_classes',101 );
function alpha_order_classes( $query ) {
    if ( $query->is_post_type_archive('artist') && $query->is_main_query() ) {
        $query->set( 'orderby', 'title' );
        $query->set( 'order', 'ASC' );
    }
}

Be advised that you cannot modify the query vars by merely changing it in the URL like what you are doing now because some themes and plugins have their own settings for controlling the number of posts on the blog index or archive pages.

Best Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.