• Resolved erickimani

    (@erickimani)


    I am trying to delete over 2000 posts ini a ceratin category.

    When I filter for any category

    WP post list –category=ID

    All the posts are listed and not the ones in the selected category

    When I use SQL

    SELECT * FROM wp_term_relationships
    WHERE term_taxonomy_id = ID

    I get zero

    Yet when I go the wordpress admin posts>categories I can see the list of categories and the number of posts under each and I can filter accordingly.

    What could be the problem and how do I fix it so as to delete a massive number of posts in a certain category susing WP CLI

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator threadi

    (@threadi)

    wp post list does not have a category option. This does not exist as a field either. Before I give you a more detailed tip on this, however, the question would be what kind of category it is exactly – i.e. the taxonomy you want to use for the restriction? For post categories it would actually be “category”, but for WooCommerce product categories it would be “product_cats”.

    Thread Starter erickimani

    (@erickimani)

    Thanks for getting back to me.

    It is a post category.

    Here is a screenshot of the backend of the wordpress blog

    https://paste.pics/3cd4a929888d8a9d7d723ef8741b7b70

    I hope that helps

    Moderator threadi

    (@threadi)

    What you are looking for should be possible with:

    wp post list --post_type=post --category_name=your_category_slug

    The value your_category_slug must be the slug of the term, not the ID of the term.

    Thread Starter erickimani

    (@erickimani)

    That worked.

    Thanks a million!

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

The topic ‘WP CLI fails to filter posts by category’ is closed to new replies.