Thursday 19 May 2016

Show post with WP_Query

<?php have_posts();
$my_query = new WP_Query( 'posts_per_page=6' );
                     while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
                     <li>
<a href="<?php echo $post->post_name; ?>">
<h2><?php the_title();?></h2>
<?php the_content( 'Read more ...' ); ?>
</a>
</li>
<?php endwhile; ?>

No comments:

Post a Comment