pagination breaks for CPT listing through a page which is front page
-
I’ve created a page template in order to sort and list all entries of a custom post type called my_event (as described in the WordPress Codex). When that page is set as the front page, you are able to navigate to paged=2 by clicking on ← Older posts but on paged=2 there’s no Newer posts → link and the em>← Older posts link points again to paged=2. What’s wrong? Any advice welcome! Thanks in advance.
<?php /* Template Name: My Template */ ?> <?php get_header(); ?> <div id="container"> <div id="content" role="main"> <?php if (get_query_var('paged')) { $my_paged = get_query_var('paged'); } elseif (get_query_var('page')) { $my_paged = get_query_var('page'); } else { $my_paged = 1; } $wp_query = new WP_Query( array ( 'post_type' => 'my_event', 'meta_key' => 'date', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'paged' => $my_paged ) ); get_template_part('loop','index'); ?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?>
- The topic ‘pagination breaks for CPT listing through a page which is front page’ is closed to new replies.