I searched around for similar problems but it did not worked for me, im a total beginner with WordPress.

I made a custom query but the pagination throwing me 404 error


$paged = (get_query_var('page')) ? get_query_var('page') : 1;

$default = array(
    'post_type' => 'dlm_download',
    'posts_per_page' => 2,
    'paged' => $paged,
    'meta_key' => '_featured',
    'dlm_download_category' => $term->slug

$args = $default;

foreach ($downloads as $download) :  setup_postdata($download); 
// loop here


$the_query = new WP_Query( $args );
                $big = 999999999; 
                $pagenum = str_replace( $big, '%#%',  get_pagenum_link( $big  ) );

                echo '<div class="pagination">';
                    echo paginate_links( array(
                        'base' => $pagenum,
                        'format' => '?paged=%#%',
                        'current' => max( 1, get_query_var('paged') ),
                        'total' => $the_query->max_num_pages
                    ) );
                echo "</div>";

And when i get http://mysite.com/?dlm_download_category=kategoria-1&paged=2

404 Error, could please someone give me a hint on this?

  • This question has been asked a lot lot lot of times. wordpress.stackexchange.com/questions/120407/… or wordpress.stackexchange.com/questions/109213/…
    – cybmeta
    Apr 23, 2014 at 8:55
  • As i highlighted, i searched, and it did not fix my problem, otherwise i would not asked Apr 23, 2014 at 9:09
  • You are defining the arguments for the query in the $default variable but then pass an unknown $args variable to the new WP_Query, appart of that kind of PHP errors, your question is almost equal to a lot of questions asked before.
    – cybmeta
    Apr 23, 2014 at 9:29
  • edited my question so you can see im passing correct data Apr 23, 2014 at 9:43
  • Sorry @LeventeNagy but you are still using undefined variables, like $downloads, and your question is still almost equal to a lot of questions here in WPSE, like the questions linked in a previous comment.
    – cybmeta
    Apr 23, 2014 at 11:24


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.