php - Submitting a Form to Display Specific WordPress Posts in a Page -


i displaying posts feature in team category using code inside page.php.

i'm listing sub-categories of 'team' in sidebar.php, listed below.

is possible in sidebar can have form lets user choose sub-categories show posts from?

visiting /?page_id=9&team=3,4 directly show posts team 3 & 4, wonder if can use form let user choose posts display.

many pointers this.

page.php:

<?php     $type = 'team';     $args=array(       '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>         <?php       endwhile;     }     wp_reset_query();  // restore global post data stomped the_post(). ?> 

sidebar.php:

<?php     $categories=  get_categories('child_of=2');        foreach ($categories $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 select box sidebar , change content of div in page.php;

like:

page.php:

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

subpage.php:

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

instead of adding text div use ajax request post. maybe read post rss, see; http://wordpress.org/support/topic/rss-feed-of-post-category

creating plugin , widget more stable solution


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -