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:
$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:
my-site.com/genres/action/page/2 – 404 error (standard link for archives)
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.