Support » Plugin: List category posts » [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']),
Viewing 12 replies - 1 through 12 (of 12 total)
  • An AND/OR option would be a great addition to this plugin!

    Question. Does ‘get_posts’ allow ‘category__and’? Or, do you mean ‘query_posts’?

    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…)

    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 …

    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']),

    Thank you!

    Cool! Glad to help 🙂

    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.

    I see there has just been an update to this plugin.

    Hoping boolean-or will be integrated.

    Plugin Author Fernando Briano


    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!


    Thank you for considering this!

    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.

    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:

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: List category posts] support for boolean-and?’ is closed to new replies.