Forums

get_posts with tag and category_name not working (3 posts)

  1. pmv
    Member
    Posted 1 year ago #

    I'm trying to make a list of posts that are in one category (let's say my_category) and also have one tag added (my_tag). I tried this:

    $args = array(
    'category_name' => 'my_category',
    'tag' => 'my_tag'
    );
    $my_posts = get_posts($args);

    but it returns nothing. If I put only one argument (either category_name or tag) I get all the right posts.

    Why can't I use those both arguments?

  2. pmv
    Member
    Posted 1 year ago #

    No one else needs this?

    Well I managed to get this working with own custom query and couldn't help noticing how complicated wordpress-database structure is. Why tags and categories doesn't have their own tables? This wp_terms, wp_term_relationships & wp_term_taxonomy structure is making queries quite complex.

    Anyway I think this really should be working with standard get_posts() -function. Hope this will be fixed.

  3. Otto42
    Moderator
    Posted 1 year ago #

    WordPress's query system does not support the combination of categories and tags at present. Version 2.7 may fix this.

Topic Closed

This topic has been closed to new replies.

About this Topic