Home Forums Front-end Issues Paged archive with 404 error


Paged archive with 404 error

  • Hi everybody,

    I try to setup a small gaming database and will use ACF for it. So far it works like I need it. But I’ve got a problem with an archive page.

    I’ve used this tutorial:

    I’ve setup 2 post types: game and genre. game has a relationship field for genre – so each games has one or more genres.

    On single-genre.php I’d like to list all ‘game’ post types with this genre. It works so far. But I need a paged archive. There is problem. When I click on page 2 (WPPagenavi or standard WordPress links) it gives me a 404 error.

    The code for single-genre.php looks like this:

    	$args = array(
    				'post_type' => 'game',
    				'posts_per_page' => 1,
    				'paged' => ( get_query_var('page') ? get_query_var('page') : 1),
    				'orderby' => 'title',
    				'order' => 'ASC',
    				'meta_query' => array(
    						'key' => 'genres', 
    						'value' => '"' . get_the_ID() . '"', 
    						'compare' => 'LIKE'
    	query_posts($args);	while (have_posts()) : the_post(); ?>
    	 <a href="<?php the_permalink();?>"><?php the_title(); ?></a><br />
    <?php endwhile; ?>
    <?php echo paginate_links(); ?>
        wp_reset_query();  // Restore global post data

    So if I use the pagination links it adds a /page/2 at the end and that gives me a 404 error. For example: – 404 error (standard link for archives)
    BUT: – works

    Does anyone has an idea how to solve this? The archive itself works, just the pagination does not work correctly. I have no further posts or pages. I’ve just setup for testing these both post types.

    Thank you for your help.

  • I’m a little confused about what you’re attempting to do.

    Just to make it straight for me and simplify it a bit.

    On the single-genre.php you are showing an archive of the games custom post type.

    You want to have pagination for the game custom post type posts.

    Is that right?

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Paged archive with 404 error’ is closed to new replies.