Live search:
$the_query = new WP_Query( array( 's' => esc_attr( $_POST['keyword'] ), 'post_type' => 'custom_type', 'sentence' => 'true' ));
if( $the_query->have_posts() ) :
while( $the_query->have_posts() ): $the_query->the_post(); ?>
<a href="<?php echo esc_url( post_permalink() ); ?>"><?php the_title();?></a>
<?php endwhile;
I created a custom post type "custom_type" and 2 taxonomies "custom_cat" (hierarchical = true) for categories and "custom_tags" (hierarchical = false) for tags.
I need to create a live search by custom tags.
I tried to set 'taxonomy'=>'custom_tags' but this parameter was ignored and search returned all "custom_type" posts by keyword. Does anyone know solution?
'taxonomy'=>'custom_tags'
, did you add it just like that to theWP_Query
arguments array? Or did you try it like'tax_query' => array( array( 'taxonomy' => 'custom_tags' ) )
?