0

I know, this question has been asked a lot. I have been through a lot of them already, but my issue seems to be more bespoke.

Initially, I had this issue, but seems to be another issue, therefore I am asking a new question in hopes for a solution.

I am using the WP Download Manager Pro plugin that creates a custom post type wpdmpro.

So, the crux of my issue seems to be that my pagination in my loop.php, seems to be connected someone to the default post type and not the custom post type I am using, as in, if I have 0 Posts in my default posts, navigating to /page/2 will not work, but if I have 11 default posts it will, but then /page/3 will not work.

I have 11 wpdmpro posts and 0 default posts. Therefore, I would expect here, that with 2 posts per page, that I would have 6 pages? Wordpress seems to think differently!

Here is my query

<?php
$category = get_queried_object(); 
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
    'orderby'           => 'date',
    'order'             => 'DESC',
    'post_status'       => 'publish',
    'posts_per_page'    => 2,
    'paged'             => $paged,
    'post_type'         => 'wpdmpro', 
    'wpdmcategory'      => $category->category_nicename,
    'tag'               => $cat_tag
);

// Query
$wpdmpro_query = new WP_Query( $args );

// The Loop
if( $wpdmpro_query->have_posts() ) : while( $wpdmpro_query->have_posts() ) : $wpdmpro_query->the_post();
?>
    <!-- Do stuff -->

<?php endwhile; ?>

    <!-- Do stuff if there are no posts -->

endif; wp_reset_postdata(); ?>

So WHY does /page/2 return a 404 when that page SHOULD exist? As mentioned, if I start to add posts to the default post (on the 11th post), then /page/2 seems to work, with the 21st post /page/3/ works, so it has to be linked to that. But why? I clearly define that I am NOT using 'post_type' => 'post',. So where could this be defined and how can I override it?

Just a few things to add in case they are somehow linked.

In my permalinks settings, I have a custom structure of

/%category%/%postname%/

and my default category base is .

I have tried resetting the permalinks settings, but still getting the 404 page on /page/2.

In my WP Download Manager Settings, my WPDM Category URL Base is .

So, with all that my url is.

{domain}/category-name/page/2/ which is returning the 404.

{domain}/category-name/ returns 2 posts of the stated category.

Part of me is concerned this is a configuration issue, mixing a custom post type with custom structure and category base. Someone out there must have had this issue? It seems like this should be very simple, but I cannot for the life of me find a solution, perhaps I am looking in the wrong places?

Any help will be massively appreciated.

Edit:

I have tried to regenerate the permalinks on multiple different occassions to no effect.

mcclosa
  • 943
  • 7
  • 29
  • 59
  • do you have tried to regenerate the permalink after a new custom post type is added? go in settings->permalinks and click on the button at the bottom of page – Sim1-81 Oct 01 '19 at 13:57
  • Yes! No luck with that. I've honestly probably done it a hundred different times – mcclosa Oct 01 '19 at 13:58
  • try to replace ` 'posts_per_page' => 2,` with `$default_posts_per_page = get_option( 'posts_per_page' );` value – Sim1-81 Oct 01 '19 at 14:03
  • Unfortunately not. Still does not change the fact that `/page/2/` does not exist and that it's still tied to the default posts and not to my custom type posts. – mcclosa Oct 01 '19 at 14:06
  • even if you change to 2 the default post per page value in settings -> reading – Sim1-81 Oct 01 '19 at 14:07
  • Already done that, changed it back to 10. Still should have a page 2, as I have 11 custom type posts. I would list everything I have done but it would be a long, long question. This has been 2 days worth of searching and hundreds of potential solutions on StackExchange. – mcclosa Oct 01 '19 at 14:10
  • this may help you https://stackoverflow.com/questions/41738362/how-to-include-pagination-in-a-wordpress-custom-post-type-query if you don't already read it – Sim1-81 Oct 01 '19 at 14:20
  • Found a solution that I have submitted as an answer. Thank you for your help! – mcclosa Oct 02 '19 at 10:45

0 Answers0