Pulling Current Category
-
Hi,
I am trying to have my single posts pull the current category (and subcategory when appropriate) in the sidebar, but I don’t know what to replace the “8” with in the following code. When I include a category number (like 8), it works great, but I can’t figure out how to automatically have it pull from the current category. Any help would be GREATLY appreciated. I am not a PHP programmer and this is my first time implementing this. Everything else on the site works great, but now I’m stuck with this final piece.
<?php if ($studiobox_sidebarfeatured_style==”Random from Category”) {
$my_query = new WP_Query(‘cat=8&showposts=1&orderby=rand’);
} else { $my_query = new WP_Query(‘cat=8&showposts=1’); } ?>Thanks!!
- The topic ‘Pulling Current Category’ is closed to new replies.