Im trying to get the category ID from
wp_dropdown_categories();and then pass the ID into a loop to have it output posts titles from that particular category.
I currently have this:
<form action="<?php bloginfo('url'); ?>" method="get"> <?php wp_dropdown_categories(); ?> </form> <div class="cat-list"> <ul> <?php global $post; $args = array( 'posts_per_page' => 5, 'category' => $_GET['value']); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; wp_reset_postdata(); ?> </ul> </div>
But it's not grabbing the category ID from the
$_GET['value'] and I'm not sure what I need to do to get it to pass that ID to the array.
Eventually, I'd like to have it so that when you select a different category that it will show the posts associated with that selected category. But I figured that I'd try to get the select to work first and then move on from there.