0

I have 3 types of posts as below

  1. Normal posts without any tag
  2. With "featured" tag
  3. With "sold" tag

On a page, I just want to show normal posts + ones with featured tag and don't want to show posts with "sold" tag. How can I do the query for this?

Thanks

  • It is always better to post the code, you have already tried. So can you please post the code you have already tried? – Maruti Mohanty Oct 23 '13 at 9:45
  • I am writing below query_posts("orderby=date&order=DESC&tag__not_in=sold"); – WebWebby Oct 23 '13 at 9:49
  • please update the same in the question you have asked. – Maruti Mohanty Oct 23 '13 at 9:51
0

It is not advised to used query_post() as it replaces the query of the page with new instance of the query. For general post queries, use WP_Query or get_posts.

here tag__not_in takes id of the tag and not the slug, so replace sold with the id of the tag sold

like

$args = array(
    'orderby'=> 'date',
    'order' => 'DESC',
    'tag__not_in' => sold_tag_ID
);

$allposts = new WP_Query($args);

Your Answer

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

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