0

I have created few metaboxes and i would like to show the post related to that particular metabox value. Just like we get the post related to tags or categories.

closed as unclear what you're asking by Pieter Goosen, Nicolai, birgire, fuxia Jun 30 '14 at 23:29

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Please provide more info. How about foreaching through all posts and isset-checking your custom fields values? – leymannx Jun 30 '14 at 14:35
  • imgur.com/xn6Bwqt ...As you can see in the image through the link i have provided..these 5stars , 4 stars etc will be the metabox text field items in the edit screen of custom post hotels. So if a user clicks over a 4 stars or 5 stars checkbox ..he should get the list of all the hotels post related to that metabox text field value. – Pankaj Kumar Jul 1 '14 at 5:53
1

Something along the lines of:

$args = array(
              'posts_per_page' => 10, 
              'post_type' => 'post',
              'meta_key' => 'METAkeyNAME', //what I assume you've called a meta box
              'meta_value' => 'THEdesiredVALUE',
              'orderby' => 'ID', //choose to order by anything look here [http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters] for more info
              'order' => 'ASC',
              );

$results = new WP_Query($args);
//    '<pre>'.print_r($results).'</pre>'; // This is a useful line to keep - uncomment it to print all results found - it can then be used to work out if the query is doing the right thing or not.
while ($results->have_posts()) {
    $results->the_post();
    the_title();
    the_content();
    echo '</hr>'; // puts a horizontal line between results
}

    wp_reset_postdata(); //re-sets back to normal       

}

Note this is untested code and completely depends what you want to get from it - need more information than "that particular metabox value" !

Not the answer you're looking for? Browse other questions tagged or ask your own question.