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:

      $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>

  <input type="submit" value="submit" name="submit"/> 



   $options = $_POST['options'];

   $query = new WP_Query( array( 'tag__in' => array( $options ) ) ); 

  while ($query->have_posts()) : $query->the_post(); 

    echo get_the_tile($post->ID);


unfortunately it is not working.

need help to get the list of post by selected tag.

  • Aside from the fact that your code in it's current form is (a) hardly readable and (b) incomplete - and you should rework the question in an edit - the problem is that you're telling us nothing where your code appears and what the context of it is, etc. Also it's unsafe (unescaped input), etc. – kaiser Feb 15 '14 at 11:56
  • question has been updated . need help. – Jack Torris Feb 15 '14 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.