i have been trying to display the post that contain specific tag.
what i am trying is: if user search for post related to tagss for example: if user selects the tag Don after submition the query will fetch post that contains don tag.
for that i have created one multiselect form. user will select multiple tags. for exapmle mama and don.
after form submit getting array of multiple selected values like:
array([0]=>11,[1]=>18)
$options = $_post['options'];
i am passing this values to new WP_Query( array( 'tag__in' => array( $options ) ) );
<form method="post" action="" multiple="multiple">
<select name="options[]" multiple="multiple">
<option value="15">mama</option>
<option value="16">chacha</option>
<option value="17">Bhatija</option>
<option value="18">Don</option>
</select>
<input type="submit" value="submit" name="submit"/>
</form>
<?php
if(isset($_POST['submit'])):
$options = $_POST['options'];
$query = new WP_Query( array( 'tag__in' => array( $options ) ) );
//print_r($query);
while ($query->have_posts()) : $query->the_post();
echo get_the_tile($post->ID);
endwhile;
unfortunately it is not working.
need help to get the list of post by selected tag.