Home › Forums › Front-end Issues › 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: http://www.advancedcustomfields.com/resources/querying-relationship-fields/
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:
<?php
$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(
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(); ?>
<?php
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:
my-site.com/genres/action/page/2 – 404 error (standard link for archives)
BUT:
my-site.com/genres/action/2 – 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?
The topic ‘Paged archive with 404 error’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.