Title: Drop Down for Posts within Specific Category
Last modified: August 22, 2016

---

# Drop Down for Posts within Specific Category

 *  [shainanz](https://wordpress.org/support/users/shainanz/)
 * (@shainanz)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/drop-down-for-posts-within-specific-category/)
 * Hello,
    I’m trying to get a drop down selector for my blog posts that only shows
   posts within a specific category. What I have looks right in that only the posts
   in that category are shown, but when I go to click on the name of the post to
   view it, it just keeps showing the most recent post even though the URL changes.
   In fact, it breaks it so much that when go to view a post from WP-Admin, it only
   shows that most recent post!
 * Here is the code I’m using:
 *     ```
       <select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;" style="width:230px;">
         <option value="" ><?php echo esc_attr( __( 'Select an Issue' ) ); ?></option>
       	<?php
       	global $post;
       	$posts = get_posts('numberposts=20&category=906');
       	foreach($posts as $post) :
       	?>
       		<option value="<?php the_permalink(); ?>"><?php the_title(); ?></option>
       	<?php endforeach; ?>
       </select>
       ```
   
 * I’ve also tried:
 *     ```
       <select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;" style="width:230px;">
         <option value="" ><?php echo esc_attr( __( 'Select an Issue' ) ); ?></option>
       	<?php query_posts('category_name=flow-trade-newsletter&showposts=20'); ?>
       	<?php while (have_posts()) : the_post(); ?>
               <option value="<?php the_permalink(); ?>"><?php the_title(); ?></option>
               <?php endwhile; ?>
       </select>
       ```
   
 * The dropdown without trying to show only one category works, and is like this:
 *     ```
       <select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;" style="width:230px;">
         <option value="" ><?php echo esc_attr( __( 'Select an Issue' ) ); ?></option>
         <?php wp_get_archives( array( 'type' => 'postbypost', 'format' => 'option', 'show_post_count' => 1 ) ); ?>
       </select>
       ```
   
 * How can I fix this? (Or is there a better solution?)

The topic ‘Drop Down for Posts within Specific Category’ is closed to new replies.

## Tags

 * [exclusion](https://wordpress.org/support/topic-tag/exclusion/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [shainanz](https://wordpress.org/support/users/shainanz/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/drop-down-for-posts-within-specific-category/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
