Title: [Plugin: List category posts] support for boolean-and?
Last modified: August 19, 2016

---

# [Plugin: List category posts] support for boolean-and?

 *  [D’Arcy Norman](https://wordpress.org/support/users/dnorman/)
 * (@dnorman)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/)
 * When passing a list of category IDs to the plugin, it uses the boolean-or query,
   so posts in any of the categories get returned – but this plugin gets even more
   useful when modified to support boolean-and, so that only posts in all of the
   listed categories are returned.
 * I’ve hacked this into my copy of the plugin, but am not sure how to implement
   it properly (so that it doesn’t break expected behaviour for people relying on
   the existing boolean-or functionality).
 * The boolean-and query is baked into WordPress now, but the query needs to be 
   modified to support it.
 * Here’s the modifed query I use, in `list_category_posts()`:
 *     ```
       $catposts = get_posts(array(
       	'category__and'=>explode(",", $atts['id']),
       	'posts_per_page'=>$atts['numberposts'],
       	'orderby'=>$atts['orderby'],
       	'order'=>$atts['order'],
       	));
       ```
   

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * (@jcollier)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732389)
 * An AND/OR option would be a great addition to this plugin!
 *  [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * (@jcollier)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732397)
 * Question. Does ‘get_posts’ allow ‘category__and’? Or, do you mean ‘query_posts’?
 *  Thread Starter [D’Arcy Norman](https://wordpress.org/support/users/dnorman/)
 * (@dnorman)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732400)
 * I took a look at the docs for get_posts, and it appears to be able to accept 
   the same args as query_posts. It just needs some tweaking (feeding an array of
   category IDs instead of a text string, etc…)
 *  [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * (@jcollier)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732403)
 * Thank you for the update.
 * I am finding that a boolean-and option is more and more significant as I am developing
   deep site architecture, yet few plugins include this option for categories, let
   alone custom post types.
 * Your information will be helpful for other plugin developers, too. I’ve already
   fowarded this thread …
 *  [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * (@jcollier)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732405)
 * Dnorman, I used your code and it works great, with one change: I changed ‘posts_per_page’
   to ‘numberposts’.
 *     ```
       '$catposts = get_posts(array(
          'category__and'=>explode(",", $atts['id']),
          'numberposts'=>$atts['numberposts'],
          'orderby'=>$atts['orderby'],
          'order'=>$atts['order'],
          ));'
       ```
   
 * Thank you!
 *  Thread Starter [D’Arcy Norman](https://wordpress.org/support/users/dnorman/)
 * (@dnorman)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732406)
 * Cool! Glad to help 🙂
 *  [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * (@jcollier)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732407)
 * BTW, it’s worth noting that category__add does not include child categories, 
   whereas id and name do.
 * I also tried initializing a new parameter name and applying it to category__add(‘
   add’ instead of ‘id’) and the result was always null.
 * So, I came back around to your original question: how to support the boolean-
   or parameter ‘id’ and also add the boolean-and parameter.
 * For the moment, this is such an important plugin and I always need category-name
   or boolean-and, so I’ll ignore the boolean-or altogether.
 *  [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * (@jcollier)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732439)
 * I see there has just been an update to this plugin.
 * Hoping boolean-or will be integrated.
 *  Plugin Author [Fernando Briano](https://wordpress.org/support/users/fernandobt/)
 * (@fernandobt)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732441)
 * I hadn’t even considered this feature, but I’ll dig into it for a future version
   of the plugin.
 * Thanks for your code and ideas, I’ll take a look at the docs from WordPress and
   come up with a way to integrate this functionality. Any more feedback is welcome!
 * Regards
 *  [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * (@jcollier)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732442)
 * Thank you for considering this!
 *  [spelverso](https://wordpress.org/support/users/spelverso/)
 * (@spelverso)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732450)
 * Hi, thanks for your work. This is the best (useful) plugin I’ve ever downloaded.
 * Jus a request. Could you add to it an option to choose not only “AND/OR” between
   2/3/… categories, but also between 2/3/… tags and also between category and tags?
   
   In example: query posts from cat1 AND tag5.
 *  [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * (@jcollier)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732512)
 * This is still one of the most important issues I’ve come across with WordPress,
   and since I use your plugin everywhere, I am hoping that you might be working
   on an AND/OR option, as mentioned by spelverso.
 * BTW, this came up in an earlier thread:
 * [http://wordpress.org/support/topic/plugin-list-category-posts-list-posts-with-two-categories](http://wordpress.org/support/topic/plugin-list-category-posts-list-posts-with-two-categories)

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘[Plugin: List category posts] support for boolean-and?’ is closed to 
new replies.

 * ![](https://ps.w.org/list-category-posts/assets/icon-256x256.png?rev=2517221)
 * [List category posts](https://wordpress.org/plugins/list-category-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/list-category-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/list-category-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/list-category-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/list-category-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/list-category-posts/reviews/)

 * 12 replies
 * 4 participants
 * Last reply from: [Sea Jay](https://wordpress.org/support/users/jcollier/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-list-category-posts-support-for-boolean-and/#post-1732512)
 * Status: not resolved