• Hi,

    I’ve got a loop for a custom post type, which I want to paginate. It seems to work fine when permalink settings are set to default (i.e. ?p=123), but as soon as I set a custom structure, it breaks, with the subsequent pages giving me the 404 page.

    I’ve tried all the various ways of defining the loop, and the result is the same for all, which is really doing my head in.

    The loop is in a page template for a page located at siteroot.com/archive/20yrsago/, and click the older posts link, takes me too siteroot.com/archive/20yrsago/page/2/ which looks correct, but it 404s.

    Here is my loop (with the code within the article trimmed):

    <?php $args = array('post_type' => 'twentyyearsago','posts_per_page' => 10,'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),);
    query_posts($args); while (have_posts()) : the_post();?>
    
    <article>Blah Blah Blah</article>
    
    <?php endwhile;?>
    
    <div class="post-nav-older"><?php next_posts_link('Older Posts', 0); ?></div>
    <div class="post-nav-newer"><?php previous_posts_link('Newer Posts', 0); ?></div>
    
    <?php wp_reset_query(); ?>

    I have the same issue elsewhere on the site with some other custom post types. Any help to get this working properly would be much appreciated

Viewing 1 replies (of 1 total)
  • Thread Starter Nathan Adams

    (@nathan-adams)

    Does anyone have any suggestions? I’ve tried hosing the htaccess file, and recreating it, with no effect.

    My htaccess is:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    and for what’s worth, the custom post type does have a rewrite:
    'rewrite' => array('slug' => 'archive/20yrsago', 'with_front' => false)

Viewing 1 replies (of 1 total)
  • The topic ‘Pagination for custom post type loop broken when permalink custom structure set’ is closed to new replies.