• I want to have a “Featured” box that will pull the latest post from the “Featured” category that coincides with the current main category (for example “Technology”). As I understand it using get_posts(numberposts=1&category=13,6) will get me the latest posts from either 13 OR 6 but I want to have the latest post that is in both categories.

    How would I go about this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    (WordPress 2.6+)

    get_posts() can also take the parameters that query_posts() can since both functions now use the same database query code internally.

    not tested but try somthing like this:

    $args = array(
    	'posts_per_page' => 1,
    	'category__and' => array(13,6)
    );
    $myposts = get_posts($args);

    Thread Starter jungalist

    (@jungalist)

    Wow! Pretty slick, thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_posts for post existing in both Catx AND Caty?’ is closed to new replies.