Support » Fixing WordPress » 404 pagination error with custom post type

  • I am currently developing a custom theme for a client and i have a custom post type that i created called Press Releases. I am loading the Press release posts on a template page labelled template-press.php. Inside this template i am running a WP_Query to fetch my press releases and then restoring the query back to the original wordpress query. The problem i am experiencing is the pagination – it keeps throwing a 404 error when i click on the Next Page link.

    The webpage can be viewed here:

    I configured wordpress to display 5 posts at a time and there a total of 10 Press Release posts. The first 5 are being displayed followed by the Next Page link but again the Next Page link takes me to a 404 error instead of displaying the next 5 Press Release posts.

    Can anyone shed some light as to why this is happening?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer




    What functions are you using for the pagination?

    Here is the code i am executing in my template file (template-press.php) to retrieve my custom post type posts:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $arguments = array(
    		'post_type' => 'post_press',
    		'post_status' => 'publish',
    		'paged' => $paged
    $press_query = new WP_Query($arguments);
    if ($press_query->have_posts()) : while ($press_query->have_posts()) : $press_query->the_post();
    endwhile else :
    'No Posts were found'

    There are two additional methods i am using that are saved in my functions.php file which are used to save and restore the global $wp_query:

    function pm_set_query($custom_query=null) {
    	global $wp_query, $wp_query_old, $post, $orig_post;
    	$wp_query_old = $wp_query;
    	$wp_query = $custom_query;
    	$orig_post = $post;
    function pm_restore_query() {
    	global $wp_query, $wp_query_old, $post, $orig_post;
    	$wp_query = $wp_query_old;
    	$post = $orig_post;
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘404 pagination error with custom post type’ is closed to new replies.