Title: WP CLI Doesn&#8217;t List Uncategorized Posts
Last modified: February 19, 2023

---

# WP CLI Doesn’t List Uncategorized Posts

 *  [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/)
 * (@wpbroken2much)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-doesnt-list-uncategorized-posts/)
 * I have usually had a great time deleting stuff with WP-CLI but today I noticed
   that despite having a few thousand uncategorized posts on a site that the following
   command fails to list anything:
 * wp post list –cat=1 –format=ids
 * If I change the category to any other it lists all the posts just not if the 
   category is 1

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-doesnt-list-uncategorized-posts/#post-16489469)
 * Are these posts really assigned the “uncategorized” category term? Or are they
   truly uncategorized by not having any assigned category term? Your command should
   work for the former but not the latter.
 * I’m unsure of the wp-cli command parameter is for no category term at all, but
   the NOT EXISTS operator can be used in the actual WP_Query object. The WP_Query
   that wp-cli ends up using could be modified to use such an operator if there 
   is no equivalent wp-cli command parameter.
 * If you have trouble with a command that should work but doesn’t, it might help
   to see what the actual SQL query was. The query can be error logged from the “
   posts_request” filter hook.
 *  Thread Starter [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/)
 * (@wpbroken2much)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-doesnt-list-uncategorized-posts/#post-16489512)
 * They are assigned to category ID = 1 which began as uncategorized but was later
   renamed.
 * It seems I can list posts by category ID for every category ID except for 1
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-doesnt-list-uncategorized-posts/#post-16492327)
 * As wp-cli is in a sense just the messenger, the fault likely lies within one 
   of the site’s plugins or its chosen theme. Try deactivating all plugins and switching
   to a default twenty* theme to see if that makes a difference. If the problem 
   persists, it could be informative to know what the actual SQL ended up being.
 *  Thread Starter [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/)
 * (@wpbroken2much)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-doesnt-list-uncategorized-posts/#post-16492921)
 * Thanks for the feedback. I just noticed another problem in which I have a couple
   thousand posts in the trash but when I run the CLI command to empty the trash
   it says there are no items in the trash at all.
 * I have to run empty trash in the admin area to empty the trash.
 * I tried using skip plugins and skip themes same problem.
 * It was emptying the trash fine until at some point last night I kept seeing notices
   of failing to delete posts in the terminal. Can’t think of any reason why WordPress
   would refuse to delete a trashed item.
 * Also, I will not break an entire site by switching the theme just to delete a
   few things. The current theme is Newspack. There are too many plugin performing
   essential tasks to start deactivating any of them
 * Finally, why would WordPress run any plugin code at all in response to a deletion?
 * This worked instantly but doesn’t change the fact that the normal CLI delete 
   function does not work.
 * wp db query ‘DELETE FROM `wp_posts` WHERE `post_type`=”post” AND `post_status`
   =”trash”;’ –skip-column-names
    -  This reply was modified 3 years, 3 months ago by [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/).
    -  This reply was modified 3 years, 3 months ago by [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/).
    -  This reply was modified 3 years, 3 months ago by [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/).
    -  This reply was modified 3 years, 3 months ago by [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/).
    -  This reply was modified 3 years, 3 months ago by [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/).
    -  This reply was modified 3 years, 3 months ago by [wpbroken2much](https://wordpress.org/support/users/wpbroken2much/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-doesnt-list-uncategorized-posts/#post-16496314)
 * Of course it’d be silly to switch themes or deactivate plugins just so you could
   do some operation. The reason for the suggestion was to ensure the issue was 
   within wp-cli itself and not due to some other influence. For testing only, not
   as a reasonable work-around.
 * When WP initializes, it loads all active theme and plugin code, whether it’s 
   needed or not. If a plugin has hooked into the query process to somehow customize
   it, it could apply this too broadly and inadvertently affect other processes 
   that it shouldn’t be affecting.
 * That query is correct for emptying trash. You are able to empty trash from WP
   admin, right? But not via wp-cli? So the correct query is failing to work from
   wp-cli only. It apparently never executes, otherwise it would have worked. It
   seems wp-cli is at least trying to execute it, otherwise you’d not see any failure
   messages.
 * My best guess is there’s some kind of breakdown in authentication so WP thinks
   you’re not authorized to delete. Doesn’t explain why category 1 doesn’t return
   results since no authentication is normally required for that.
 * I think you’re going to need someone better versed in the inner workings of wp-
   cli to help you resolve this. Because I’ve cluttered up this topic with a bunch
   of replies, it is much less likely to get the attention of anyone else. We normally
   discourage the re-posting of topics, but it’d be the best way to get the attention
   of someone more knowledgeable of wp-cli. Go ahead and do so with my blessing.
   Include everything you’ve done to investigate to avoid re-trodding over the same
   ground again. I recommend using a different title so it doesn’t look like a duplicate
   topic.
 * I’ll leave a note in your account saying I recommended re-posting in case anyone
   should question it.
 *  [Sergio Scabuzzo](https://wordpress.org/support/users/seedsca/)
 * (@seedsca)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-doesnt-list-uncategorized-posts/#post-16496795)
 * Hi [@wpbroken2much](https://wordpress.org/support/users/wpbroken2much/),
 * Seems there were other [category parameters](https://developer.wordpress.org/reference/classes/wp_query/#category-parameters)
   to try, like `--category_name`, or `--category_in`, to do some troubleshooting.
 * Though, in the end you likely needed to run [`wp post list`](https://developer.wordpress.org/cli/commands/post/list/)
   with `--skip-plugins` and `--skip-themes` to be sure no plugins, or themes, were
   creating a conflict.
 * Hope this helps somebody else…
    -  This reply was modified 3 years, 3 months ago by [Sergio Scabuzzo](https://wordpress.org/support/users/seedsca/).

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

The topic ‘WP CLI Doesn’t List Uncategorized Posts’ is closed to new replies.

## Tags

 * [wp-cli](https://wordpress.org/support/topic-tag/wp-cli/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [Sergio Scabuzzo](https://wordpress.org/support/users/seedsca/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/wp-cli-doesnt-list-uncategorized-posts/#post-16496795)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
