WordPress show other posts in category on story page(single.php)

foreach($category_ids as $cat_id) {
$category_id .= $cat_id->term_id . ‘, ‘;
$category_id = substr(trim($category_id), 0, -1);
$args = array(
‘cat’ => $category_id,
‘order’ => ‘DESC’,
‘posts_per_page’ => 5,
‘post__not_in’ => array($post->ID)
$the_query = new WP_Query($args);
if ($the_query->have_posts()) { ?>
have_posts()) : $the_query->the_post(); ?>
<a href=””>

Change your html according to your theme.


About Kapil Chugh

In love with PHP and tweaking WordPress. Hungry for Open Source and new technologies. Honest. God-fearing. Happiest when solving problems.
This entry was posted in WordPress and tagged . Bookmark the permalink.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s