WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] what the @#$! is wrong with post filtering? (9 posts)

  1. gmorehoudh
    Member
    Posted 5 years ago #

    I am practically beside myself at this point. I'm trying to exclude posts with a certain category from feeds (primarily) and the home page (would be nice but less necessary) when a certain GET variable is set. Also tried this with a tag. The tag__not_in and category__not_in functionality appears to be simply NOT WORKING. $query->set('cat', '-[id]') also fails with the exact same symptoms.

    What happens is when I use any of the three methods I've tried, many posts disappear even though I only have ONE post that meets the exclusion criteria. I've checked that I'm using the right category id. I've disabled and deleted all other plugins that would touch categories and such, and commented out my other functions, and nothing works.

    I have a ticket on trac about this: http://trac.wordpress.org/ticket/7798

    As far as I can tell I've found a bug. Does anyone know different or can help me out? I'm on the verge of hacking a method of exclusion into the several related files in my theme, which is NOT the right or ideal way to do this.

  2. gmorehoudh
    Member
    Posted 5 years ago #

    I've partially figured out what is happening here. Posts aren't actually improperly disappearing. Instead, they are being spit out in an apparently random order, instead of descending by date as they should be. When I scrolled back through all the older entries on the blog's home page, the posts appeared to be all there but completely in the wrong order, both on the main blog and the feed.

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    I can't find a bug there, so I think that you must be doing something else that's mucking it up. I have no idea what it could be though.

    Have you tried looking at the actual SQL query being generated?

    In your wp-config.php file, add this line of code to the top:
    define('SAVEQUERIES', true);

    Then, in you can do this to dump all the queries and how long they took:

    if (SAVEQUERIES) {
    global $wpdb;
    echo '<!--\n';
    print_r($wpdb->queries);
    echo '\n--!>';
    }

    Find the query that's being generated by your code and see what the heck is wrong with it.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    It just hit me: GROUP BY. That's probably your problem.

    If your posts are appearing in REVERSE ORDER (oldest first), then that's definitely it.

    Your version of MySQL has a bug:
    http://wordpress.org/support/topic/154622

  5. gmorehoudh
    Member
    Posted 5 years ago #

    I find that when I comment out my code, I can affect the display of posts using query_posts() in my theme's index.php, for example to reverse the sort order and such. If any of my various functions I've tried to exclude the category with are enabled, I cannot affect the display of posts with query_posts().

    I'll try your suggestion and see what I get.

  6. gmorehoudh
    Member
    Posted 5 years ago #

    Oy vey. We are indeed running 5.0.51a-log.

    They're not appearing exactly in reverse order. It's -almost- reverse order, generally ascending, but there are some that are randomly sprinkled around.

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Note that the current trunk may not exhibit the same issue, as a whole bunch more "GROUP BY" bits were removed yesterday (they were unnecessary due to other changes). The MySQL bug in question is specific to group by queries.

  8. gmorehoudh
    Member
    Posted 5 years ago #

    We're going to rebuild our stack with MySQL 5.0.67 and see if that helps.

  9. gmorehoudh
    Member
    Posted 5 years ago #

    Upgrading to MySQL 5.0.67 solved this issue for us. It is a bug in MySQL, not WordPress.

    See the trac ticket above and the link Otto42 posted for details. Thanks Otto for all your help.

Topic Closed

This topic has been closed to new replies.

About this Topic