Support » Fixing WordPress » Pagination not working with "pretty" url structure ?

  • Resolved Xeevee


    Hi all,

    I’m creating a theme and have added pagination support to it, and it appears to work perfectly when using the “default” permalinks setting:

    http://********* for example,

    but when I’m using a custom structure of the format “/%category%/%postname%” such as:


    it simply returns my 404.php template when I try to go to another page, but the default page with no parameters displays fine:


    I’m using a custom WP_Query to get items of my custom post type “news” to display on a page.

    Code for the query is as follows:

    $args = array(
    	'post_type' => 'news',
    	'post_status' => 'publish',
    	'posts_per_page' => 2,
    	'paged' => $paged
    $news_query		= new WP_Query($args);

    I’ve var_dumped the $paged variable on my 404.php template and it’s returning “int(0)” but when I dump it on the page-news.php template using the “default” Permalinks structure page is being returned correctly.

    So it appears when switching to the custom Permalink structure that my “$paged” variable is no longer being correctly retrieved from the URL.

    Any advice / pointers would be greatly appreciated.

    – Jack

Viewing 1 replies (of 1 total)
  • After a lot of Googleing around I managed to find the problem and the solution.

    Simply put you cannot have a custom post type’s name and and page’s slug the same.

    In my case I had the custom post type “news” and then a page called “news” with the slug “news” to display the custom post type’s posts.

    However this causes conflict with WordPress’s rewrite rules and as a result was triggering my 404 error.

    The solution was simply to change the “news” page’s slug to “latest-news” or anything other than “news” actually.

    No more conflict, and working pagination! =D

    – Jack

Viewing 1 replies (of 1 total)
  • The topic ‘Pagination not working with "pretty" url structure ?’ is closed to new replies.