I’m currently using Magic Fields2 to use Custom Post Types, WPML for multilingual and few others which are not related to my problem.
I would like to render posts on the blog page, with 8 post per page (currently, I use 1 to do tests).
I had some fields to the original post type and so I now have to use it as a custom post type.
I’ve got some difficulties to do an effective pagination which lead to something else to a 404 page.
Here is my code currently, but It doesn’t stop moving to find a solution.
My page where this code is written is called “blog” and the origin post type is called “post”.
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); $wp_query->query('post_type=post&posts_per_page=1'.'&paged=' . $paged); if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <article> MY CONTENT </article> <?php endwhile; ?> <nav> <div class="nav_post"><?php previous_posts_link("« Précédants") ?></div> <div class="nav_post"><?php next_posts_link("Suivants »") ?></div> </nav> <?php endif; ?>
Does someone would help me to figure out how to implement a good pagination (numbers/previous-next) ?
And after this first step, how to setup this page/2/ without to go on a 404 page ?
- The topic ‘Pagination and Loop for Custom Post Type’ is closed to new replies.