0

Example:

  • 4 most recent regular posts

  • 6 posts queried from custom post type

  • 8 regular posts ( most recent posts with a 4 post offset so that it's a continuation of the first four posts on the page)

  • pagination (for regular/recent posts, not custom post type)

Thank You.

1 Answer 1

0

I'd make a loop with 12 posts per page and after printing 4 posts I'd call another loop with 6 custom posts. Then go back and print the last 8 posts of current page.

<?php

    $index = 1;

    $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;

    $posts = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 12, 'paged' => $paged));

    if ($posts->have_posts()) : while ($posts->have_posts()) : $posts->the_post(); ?>

        <article>
            <h2><?php the_title(); ?></h2>
            <p><?php the_excerpt(); ?></p>
        </article>

    <?php

        if($index == 4){
            $custom = new WP_Query(array('post_type' => 'CUSTOM-POST-TYPE', 'posts_per_page' => 6));
            if ($pcustom->have_posts()) : while ($pcustom->have_posts()) : $pcustom->the_post(); ?>

                <article>
                    <h2><?php the_title(); ?></h2>
                    <p><?php the_excerpt(); ?></p>
                </article>
    <?php
            endwhile; endif;
        }

        $index++;

    endwhile; endif;


    wp_pagenavi($posts);

?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.