0

i am having a little trouble here. Well what i am exactly trying to do is post posts into different divs in my wordpress template in a single page. enter image description here

How am it to achieve different posts in different divs.

1
  • 1
    can you explain more? single.php is usually used to display a single post. What are the other different posts?
    – Karun
    Jul 6, 2015 at 12:41

1 Answer 1

-1

Add the below code in your single.php file

<div class="post-contents">
<?php
$args = array( 'posts_per_page' => -1,'orderby'=> 'date','order'=> 'DESC','post_type' => 'post','post_status'=> 'publish');
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
    <div class="post-single">
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                <p><?php echo $post->post_content; ?></p>
    </div>
<?php endforeach; 
wp_reset_postdata();?>
</div>

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.