I’m not sure if my topic title is even clear, so I will do my best to explain what I’m trying to do.
I created a custom post type called, “Books.” On my home page (using a custom template), I’d like 3 Book posts to be displayed beside each other. Using HTML/CSS I would just create 3 separate divs and float them all to the left. However, when inserting my code to call the 3 Book posts, I don’t know how to do this.
What should be PHP code look like on this page? Right now, it looks like this:
<div class="booksSection"> <?php $args = array( 'post_type' => 'book', 'posts_per_page' => 3 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); the_title(); echo '<div class="entry-content">'; the_content(); echo '</div>'; endwhile; ?> </div>
- The topic ‘How to display multiple custom post types in separate divs on a page template’ is closed to new replies.