• 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.