How to show posts that don’t have a specific category

[ad_1]

The answer here with the most upvotes is I think quite appropriate for this:
https://wordpress.stackexchange.com/questions/159302/show-posts-without-term

I am not aware of a way off PHP to do this.

If you’re using WordPress, you can use the following query in the MySQL database to retrieve all posts that don’t have a specific category:

SELECT * FROM wp_posts
LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE wp_term_relationships.term_taxonomy_id IS NULL;

Replace wp_posts and wp_term_relationships with your own database table prefix, if it’s different.

Note: Before executing any queries on your database, make sure to backup your data.

Thread Starter
JanLho

(@janlho)

Hi guys, thank you for your replies. Unfortunately I have no clue on how to access or query a SQL DB. Any other possibilities?

Thread Starter
JanLho

(@janlho)

OK I’ve found a workaround: I exported all posts into a csv and was able to locate the one posts without certain category in the csv 😉

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer