• Resolved ohsheglows

    (@ohsheglows)


    Hi I recently have been trying to migrate my wordpress.com blog to a www.ads-software.com version 2.7 version. The import of items appeared to go good, All posts exist, some sub categories got duplicated in the import but all the categories are there. Although the categories don’t seem to have the correct numbers of posts in them, all but 5 categories (out of 50 or so) have 0 posts. When I go to my posts they show that they are in all the correct categories.

    Also when I add a category widget it will only list the categories that it thinks it has posts in. Can someone explain to me when you add the categories widget how it queries the database? Or how it determines what posts are linked to what categories?

    Everything I check in the database appears to be correct.

    – An ID in wp_posts correlates to an object_id in wp_term_relationships
    – In which there will be a few rows (depending on how many categories that post is linked to)
    – Then you can look up term_taxonomy_id in wp_term_relationships which is also listed in the wp_terms table in which you can link it to a term_id.
    – Then the term_id row has a name column which is the names of my Categories

    Maybe this isn’t the way it tries to pull the category links but possibly someone can give me some more understand to what might be happening and how I can fix it.

    Also the “post_category” int(4) column in the wp_posts table has a 0 value across the board… What is this column for, possibly this is where my problem lies?

    When I do the command <?php wp_list_categories(‘show_option_all&hide_empty=0’); ?> It will list all my categories on the page, so obviously it is thinking almost all of them are empty. But when I click on the category link it will bring up a post in that category. I guess there must be a SQL command that I can run to update my database regarding my categories…

    Thanks,

Viewing 4 replies - 1 through 4 (of 4 total)
  • i think you just need to update your permalinks
    admin – settings – permalinks

    Thread Starter ohsheglows

    (@ohsheglows)

    I think I found the issue… In the database in the wp_term_taxonomy table the “count” column is 0 across the board (except for a few categories). How can I update the count column to the correct numbers?

    Thread Starter ohsheglows

    (@ohsheglows)

    I figured out the SQL command to get the count field updated which in turn fixed my category listing problem. Here is the command below:

    UPDATE wp_term_taxonomy
    SET wp_term_taxonomy.count =
    (SELECT count(wp_term_relationships.term_taxonomy_id)
    FROM wp_term_relationships, wp_posts
    WHERE wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
    AND wp_term_relationships.object_id = wp_posts.ID
    AND wp_posts.post_type = ‘post’)

    That sql command fixed it for me, but as soon as I deleted a post, it went back the way it was. Looks like whatever’s automatically setting the ‘count’ column in wordpress is doing it wrong! I’m still using 2.6.3 on this site though, so maybe it’s completely unrelated to what you’re seeing.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress Categories Not linked through posts’ is closed to new replies.