Getting single category for WP_Query
-
I currently have the following code which I use for showing more posts within my single.php after the content.
<?php global $post; $args = array('showposts' => 3, 'post__not_in' => array( $post->ID )); query_posts( $args ); if (have_posts()) : while (have_posts()) : the_post(); ?> [html stuff here] <?php endwhile; wp_reset_query(); endif; ?>
However I would like to add a category parameter to pull more posts depending on the category the original post is filed under.
'category_name' => '[code here to get the category name within single.php]'
For instance, let's say my Post is filed under technology, I would like pull more technology related posts with the above query. However since I have multiple categories, is there a way to dynamically pull the category the post is filed to so that it can choose the relevant stories?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Getting single category for WP_Query’ is closed to new replies.