WordPress.org

Ready to get started?Download WordPress

Forums

[BUG] Custom Taxonomies - Post count completely wrong (2 posts)

  1. defade
    Member
    Posted 3 years ago #

    Hi...

    I've just set up some custom taxonomies on our blog.

    Basically they are just some custom tag-clouds for a few different subjects

    They were very easy to set up

    But i've come across what appears to be a weird bug

    I've no idea how to use that core-trac thing or even find out if this is a known bug (i did search the support forums - but found nothing listed)

    So after creating my custom taxonomies, i went through my articles (posts) using the bulk edit function to 'tag' all the articles in the new custom tag-subjects

    By using the bulk-edit feature, this saved me loads of time, but in doing so meant i could only add one tag at a time - however, cetain articles needed to be tagged with multiple tags, so they would show up in the bulk edit many times

    Here's where it got weird....

    Every time i added a new tag to a post and hit the 'update' button, it would increse the post count for that article by +1

    I know that sounds a bit crazy, as an article does not have a post count, so the best way to explain it is with an example

    1) Go to our sites archive page HERE

    2) Look over to the right for a new custom "Drivers" tag-cloud

    3) Near the top is is a driver called "Colin Goodswen"

    4) Hover your mouse on this driver and it says "11 Topics"

    5) Click the name though, and you'll find he has just ONE topic

    The reason for this is simply because i had to add multiple "driver" tags to that article, and each time i hit the "Update Post" button it (as i said before) increased the post count for that article by +1

    And it's not just a one-off... virtually EVERY single driver tag has the incorrect post count assigned to their name

    --------------------------

    So i kind of need help in a couple of ways...

    First off.... can someone who understands what they are doing with WordPress Core-Trac, find out if this is a know bug - and if not, could they kindly file a bug report for me

    But secondly... does anyone have the slightest idea how i can fix the post count and set it back to the correct numbers...

    It's not just the fact it's giving wrong information to our readers, it also means our tag-cloud's appearance is completely wrong, and tags with only one article are being emphasized over other tags with many articles

    Many thanks for reading

    - ADE

  2. vtxyzzy
    Member
    Posted 3 years ago #

    I believe you can set the post count with a query like this:

    UPDATE wp_term_taxonomy tt1
    SET count =
    (SELECT count(p.ID) FROM  wp_term_relationships tr
    LEFT JOIN wp_posts p
       ON (p.ID = tr.object_id AND p.post_type = 'post' AND p.post_status = 'publish')
    WHERE tr.term_taxonomy_id = tt1.term_taxonomy_id)
    WHERE tt1.taxonomy = 'category'

    Just be sure to back up the table first.

    Change the table prefix from 'wp_' to your own prefix.
    Set the tt1.taxonomy to your own taxonomy.

Topic Closed

This topic has been closed to new replies.

About this Topic