Custom post types in split loop
-
Hey everyone,
I’ll get right to the point. My website is brokenstars.de and on the front page (index.php) there’s a loop that shows one bigger entry at the top and three previews of the next ones. If you paginate it only shows four previews instead of a bigger entry on top. That’s how I wanted it and everything works perfectly, even the pagination. Here’s the code I’ve used in my loop:<?php $paged = $wp_query->get( 'paged' ); if ( ! $paged || $paged < 2 ) : $args = array( 'post_type' => array('post','tutorials'), 'posts_per_page' => 1 ); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?> // Here's the stuff for the first entry <?php endwhile; endif; while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate ) continue; ?> // Here's the stuff for the next three entries <?php endwhile; ?>You can see that I’ve tried to include my custom post type “tutorials”. If I create an entirely new query like the first one with other arguments for the three last entries the tutorials get shown but the pagination is broken and it will always show the last four entries if you paginate. But else, with the working code above it just doesn’t show the tutorials at all. Spelling mistakes are impossible, I’ve checked several times. It clearly recognizes the argument for posts per page, but it just doesn’t get the post type argument.
Did I place it wrong? Or is there something else I have to consider?
Thanks for your help 🙂
The topic ‘Custom post types in split loop’ is closed to new replies.