#StackBounty: #custom-post-types #ajax #pagination How to load custom post archives sub-pages with ajax?

Bounty: 50

I’d like to keep the pagination links for /page/2/, /page/373/, etc but instead of changing the URL on the browser i want everything to load on the archive main page.

Ideally all those paginated URLs should redirect to the first page of the archive.

I don’t want a “load more” button i want to keep the logic of pages but load them via ajax keeping url unchanged.

How can i do this? Any help is appreciated.


Get this bounty!!!

#StackBounty: #custom-post-types #wp-query #categories WP_Query with custom post_type and cat retrieving unwanted posts with the custom…

Bounty: 50

I have a custom post type “projets” that is using the category taxonomy (so it is sharing categories with regular posts).

When I call WP_Query like this:

$args = array(
    'post_type' => 'projets',
    'posts_per_page' => 6,
    'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1,
);
$projects = new WP_Query($args);

It works perfectly fine.
But when I add a category to the arguments like this:

$args = array(
    'post_type' => 'projets',
    'posts_per_page' => 6,
    'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1,
    'cat' => 39
);
$projects = new WP_Query($args);

It does not returns only projets custom post_type but also regular posts that share the category 39…
Is there a way to make sure only the custom post type will be returned?

For info I use the Custom Post Type UI extension to declare the post type, I did not declare them myself.


Get this bounty!!!