determining the variable for $category =
-
I am trying to get this piece of code to bypass the theme’s options for what category populates a slider on my site’s posts, such as this one: https://www.theresident.net/web-video/your-part-in-global-warming/
The reason I’m trying to bypass the options in the theme options menus is because I have the slider on the homepage set to show all categories in that theme options menu (which works fine), but I’d like the slider on the post pages to show posts that are within the same category of the selected post alone.
I’d like the slider to be populated with the category “web-video” in the above example. The code that determines what category populates the slider is below. I am guessing I should remove the “if $myOptions” portions and just set the $category = and the $posts = to what I want. When I put in the number for $posts = , I see the correct number there. But I am not sure what to enter for $category = to populate the slider with the category reflected in the post’s slug. Any help would be great!
<?php $page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
if ($myOptions[‘bottom_cat’]) {
$category = $myOptions[‘bottom_cat’];
} else {
$category = 0;
}
if ($myOptions[‘bottom_posts’]) {
$posts = $myOptions[‘bottom_posts’];
} else {
$posts = 0;
}
query_posts(“cat=$category&paged=$page&posts_per_page=$posts”);
while ( have_posts() ) : the_post() ?>
- The topic ‘determining the variable for $category =’ is closed to new replies.