0

We have set WordPress to assign a default category to new posts, as it does anyway by default. Yet, when I check in the database, there is no category set on e.g. a post I just created. Is this because WordPress adds this just via code, and not in the database?

I have a filter which shows posts based on some categories, and when the category isn't set in the database, the post isn't showing.

Is there something wrong, or do I have to find a way to work around this?

EDIT: The problem is that the category set as the default category doesn't appear on the posts in the database. Because of that, I can't filter posts by it.

  • I typically just rename uncategorized to the category I want it to be the default one, as uncategorized is the default category. – gdaniel Nov 8 '16 at 20:14
  • @gdaniel The problem is that the category set as the default category doesn't appear on the posts in the database. Because of that, I can't filter posts by it. – ptf Nov 9 '16 at 8:52
  • Where in the database are you checking? you should be able to find all the categories/terms under wp_terms, and the relationship between categories/terms and posts in the wp_term_relationships table. – gdaniel Nov 9 '16 at 14:59
  • If I run this query select * from wp_term_relationships where object_id = 1234;, and 1234 is the post id, I would get no results. There are no entries in the wp_term_relationships table for that post. Do I have to create a workaround for this? – ptf Nov 9 '16 at 15:35
  • you might be having other issues then, I just checked and after creating a new post, and adding it to the uncategorized category, I see the relationship created in the wp_term_relationships table. – gdaniel Nov 9 '16 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.