Displaying posts from a category on single post page based on meta key values
-
I display a list of popular posts based on a meta key value in sidebar on single post page like this-
if ( is_single() ) { $thiscategory=single_cat_title("", false); $category = get_the_category(); $catm=$category[0]->cat_name; echo'<h3>Most Viewed Videos in '.$catm.'</h3>'; query_posts('v_sortby=views&v_orderby=desc&category_name='.$catm.'&showposts=5');// v_sortby and v_orderby are by a plugin if ( have_posts() ) : while ( have_posts() ) : the_post(); {?> <a href="<?php the_permalink(); ?>"><?php echo the_title2('', '...', true, '40'); ?> //the_title2() is a function to shorten the titles
My problem is that this code sometimes display the posts from the same category as of the post on single page but other times it display posts from categories other than post category.
What is wrong with the code?
- The topic ‘Displaying posts from a category on single post page based on meta key values’ is closed to new replies.