I’m using a query to show the latest post in the “Featured” category by using this code:
<?php if (! is_paged()): $my_query = new WP_Query('category_name=Featured&showposts=1'); $wp_query->in_the_loop = true; while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
Thing is, I want the user to be able to choose which category they want to be their “Featured” category. I have a variable (via Theme Options) with the correct category, thing is, I don’t know how to pass this variable into the query above, particularly this line right here:
$my_query = new WP_Query('category_name=Featured&showposts=1');
I can’t put a variable in there because it’s surrounded with ‘ ‘. IF I remove the ‘ ‘, I get an error.
- The topic ‘Quick PHP Question’ is closed to new replies.