WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] post_category field in wp_posts table - why all zeros? (4 posts)

  1. deko
    Member
    Posted 8 years ago #

    Why is the post_category field 0 for all my posts in the wp-posts table? I've assigned everything to a category and can see the id's in the admin pages.

    I'm looking for a way to construct a select statement that will count all posts in a particular category.

    can't use template tag here...

  2. Assignment of categories to posts is in the wp_post2cat table. This allows for multiple categories per post.

    I'm not at all sure what the post_category field is there for.

  3. deko
    Member
    Posted 8 years ago #

    10-4. Thanks!

  4. deko
    Member
    Posted 8 years ago #

    Actually, there is a category_count field in the wp-category table that provides the total posts in each category.

    The real problem is trying to get can aggregate comment count for each categroy... because there is no category_id FK in the wp-categories table... because a comment can belong to a post in multiple categories...

    I guess an aggregate comment count would be meaningless anyway. You could have 10 comments and 10 categories total in your database, and each category would show a total of 10 comments if the post was in all 10 categories - so you would think you had 100 comments when you only had 10.

Topic Closed

This topic has been closed to new replies.

About this Topic