How To Create a Custom Page with Posts From Specific Category in WordPress

You need to use a plugin that will enable you to execute PHP code on your post or page. You can use EXEC-PHP plugin for wordpress. After installing one of the plugin above, activate and configure them to suit your needs. Once done configuring the plugin, you may now paste the below code on your post or page. Don’t forget to change the category ID[1] and number of post[2] you want to display on the post or page.

<?php $recent = new wp_query("cat=[1]&showposts=[2]"); while($recent->have_posts()) : $recent->the_post();?>
<h4><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
<p><?php the_excerpt(); ?></p>
<div class=”post-meta”>Posted by <?php the_author_posts_link(); ?><?php echo get_the_date(); ?></div>
<?php endwhile; ?>

The above code must be inserted within the wordpress loop.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s