0

I am working on a theme with a front page that will have two loop sections. The first will loop three posts from a Custom Post Type (ill-portfolio), the second will loop three blog posts. In both instances I want the posts to be generated in a <ul>. I am also using the Advanced Custom Fields plugin on the page.

Can anyone tell me what I am doing wrong? Any help is appreciated!

<section id="recent-work-wrapper" class="row">

    <aside id="recent-work" class="col-3 float">
        <h3><?php the_field('home_work_title'); ?></h3>
        <p><?php the_field('home_work_paragraph'); ?></p>
    </aside>

    <!--CUSTOM POST TYPE LOOP-->
    <ul class="home-recent-posts">
        <?php 
            query_posts('post_type=ill-portfolio&posts_per_page=3');
            if (have_posts()) : while (have_posts()) : the_post();?>
        ?>

        <li class="home-single-post col-3 float">
            <?php the_post_thumbnail(); ?>
            <h5><?php the_title(); ?></h5>
            <?php the_excerpt(); ?>
            <a href="<?php echo get_permalink(); ?>">View Project</a>
        </li>

        <?php endwhile; endif;?>
    </ul>

</section>

<!--Recent Posts Section-->
<section id="recent-posts-wrapper" class="row">

    <aside id="recent-posts" class="col-3">
        <h3><?php the_field('home_posts_title'); ?></h3>
        <p><?php the_field('home_posts_paragraph'); ?></p>
    </aside>

    <!--BLOG POST LOOP-->   
    <ul class="home-recent-posts">
        <?php 
            if (have_posts()) : while (have_posts()) : the_post();?>
        ?>

        <li class="home-single-post col-3 float">
            <?php the_post_thumbnail(); ?>
            <h5><?php the_title(); ?></h5>
            <?php the_excerpt(); ?>
            <a href="<?php echo get_permalink(); ?>">View Project</a>
        </li>

        <?php endwhile; endif;?>
    </ul>

</section>
0

While using query_post(), you can reset the query at the end by using

<?php 
        query_posts('post_type=ill-portfolio&posts_per_page=3');
.
.
.
<?php endwhile; endif;?>

<?php
// Reset Query
wp_reset_query();
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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