Submitting a Form to Display Specific WordPress Posts in a Page

I am currently displaying Posts that feature in my Team category using the code inside Page.php.

I'm also listing the sub-categories of 'Team' in my Sidebar.php, also listed below.

Is it possible in my Sidebar that I can have a form that lets the user choose which sub-categories to show posts from?

Visiting /?page_id=9&team=3,4 directly will show Posts from Team 3 & 4, but I wonder if I can use a Form to let the user choose which posts to display.

Many thanks for any pointers with this.


    $type = 'team';
      'post_type' => $type,
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1,
      'cat'=> 3
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>

                <h2>Team Name: <?php the_title(); ?></h2>
    wp_reset_query();  // Restore global post data stomped by the_post().


    $categories=  get_categories('child_of=2'); 
      foreach ($categories as $category) {
        $option = '<li><label>'.$category->cat_name.'</label><input type="checkbox" name="team" value="'.$category->term_id.'" style="float:right" /></li>';
        echo $option;


You can add a select box to the sidebar and change the content of a div in your page.php;



<div id="content"></div>


<select id="category">
    <option value="">Select your team</option>
    <option value="Team 1">Team 1</option>
    <option value="Team 2">Team 2</option>
    <option value="Team 3">Team 3</option>
$('#category').change(function() {
        if(this.value) $('#content').html(this.value);

Instead of adding a text to your div you could use an ajax request to get your post. Maybe read the post from RSS, see;

Creating a plugin and widget will be a more stable solution

Need Your Help

C relocation 0 has invalid symbol index


First of all, I am sorry for possible nonsense somewhere in my code, I am more then a beginner.. I am trying to compile this code with

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.