Skip Navigation

[Resolved] Custom post archive pagination URLs

This thread is resolved. Here is a description of the problem and solution.

Problem: The custom post archives set up by WordPress include paginated URLs like:
@http://yoursite.com/psychologists/
@http://yoursite.com/psychologists/paged/2/
@http://yoursite.com/psychologists/paged/3/

However, the WordPress Archive I am using to display these posts is not paginated. Now these URLs contain the same content, which is bad for SEO. I would like to set my WordPress URL pagination so that these URLs do not exist if they are not needed.

Solution:
Modify the pagination settings programmatically like so:

function change_posts_per_page_in_archive( $query ) {
    if ( is_post_type_archive('book') ) {
       $query->set( 'posts_per_page', 100 );
    }
}
add_action( 'pre_get_posts', 'change_posts_per_page_in_archive', 999 );
This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by emilyB-2 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#924208

Hello,

I have the custom post psychologists.

It seems like the archive displays the same content on the following URLs :

hidden link
hidden link
hidden link
and so on...

These are being seen as duplicates SEO-wise.

Is there a way to deactivate pagination on custom posts archives made with toolset?

Thank you

François

#924289

Hi, can you tell me how many psychologist posts exist on your site? In other words, is the display here limited? Also please go to wp-admin > Settings > Reading and let me know the setting for Blog pages show at most.

#924296

Hi,

The setting is at "6" and I have more than 6 psychologists.

That might be was is happening... I'm using a customized archive for that custom post that ignores pagination, but plugins believe that the archive is paginated.

Is this it?

If so, is there a way to set to post limit individually, per custom post type?

Thank you,

François

#924376

Sure, you can set the posts_per_page for a specific archive using code like this:

function change_posts_per_page_in_archive( $query ) {
    if ( is_post_type_archive('book') ) {
       $query->set( 'posts_per_page', 100 );
    }
}
add_action( 'pre_get_posts', 'change_posts_per_page_in_archive', 999 );

Change book to the slug of your psychologists post type, and change 100 to set the number of posts per page.

#924383

Very nice, thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.