I'm relatively new to PHP so please forgive if this is a newb question... I'm trying to use the WP_Query class to display a specific category blog post. I have it hooked into a theme admin panel where the user chooses which category posts he/she wants to display. My problem is I don't know how to display that chosen category name correctly inside WP_Query. Here is what I have so far: <?php $category1 = get_option('uf_first_feat_cat'); $recent = new WP_Query('cat='.$category1.'&showposts=1'); while($recent->have_posts()) : $recent->the_post();?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <p class="cat-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_titlesmall('', '...', true, '25') ?></a></p> <!-- POST CONTENT --> <div class="post_content"> <?php $thumbnail = get_post_meta($post->ID, "Thumbnail", $single = true); ?> <img id="cat-thumb-left" src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $thumbnail; ?>&h=120&w=275&zc=1" align="left" alt="" /> <!-- POST META --> <p class="home-post-details">Posted in <?php the_category(', ') ?> on <?php the_time('m/d/y') ?></a></p> <?php the_excerpt(); ?><span class="readmore"><a href="<?php the_permalink(); ?>">Read More</a></span> </div> <!-- end #post_content --> <?php endwhile; ?> </div> <!-- end #post-cat# --> PHP: ...where $category1 is the chosen category by the user. Now how to do define that variable in the second line with WP_Query? This is what I tried so far and it doesn't work. Anyone know what I'm doing wrong here? WP_Query('cat='.$category1.'&showposts=1'); PHP:
I've solved my own problem. It had nothing to do with formatting incorrectly. I needed to use 'category_name' instead of 'cat' in the WP_Query $args. Otherwise it was calling the category NUMBER instead of the category NAME (which is what I wanted).