its my page-ajax.php file
define('WP_USE_THEMES', false); require_once('../../../wp-load.php'); $terms = get_terms( 'bk-category' ); foreach ( $terms as $term ) { } $bkcat = $term->term_id; $args = array( 'posts_per_page' => -1, 'category' => $bkcat, 'order' => 'ASC', 'post_type' => 'bk-post', ); $the_query = new WP_Query($args); if($the_query->have_posts()) { ?> $i = 1; while($the_query->have_posts()) : $the_query->the_post(); $a = $i++; endwhile; }
and this my page-table.php file
global $post; $terms = get_terms( 'bk-category' ); $select = "n"; $select.= "Select categoryn"; foreach($terms as $term){ if($term->count > 0){ $select.= "slug."'>".$term->name.""; } } $select.= ""; echo $select; $(document).ready(function() { var dropdown = document.getElementById("cat"); function onCatChange() { if ( dropdown.options[dropdown.selectedIndex].value != -1 ) { $('.results').html("/images/loading.gif' />"); $.ajax({ type: 'POST', async: true, dataType : "html", url: "/page-ajax.php", success: function (data){ $('.results').html(data); } }); } } dropdown.onchange = onCatChange; });
In this case all shows or All Categories Shows , but : I just want to show only the contents of each category is clicked