• Hi Justin,

    Thank you for the great plugin Query Posts. It is extremely versatile.

    I am trying to use it in combination with the plugins Widget Logic and WP Post Views to show a list of most viewed posts belonging to a certain category and only visible when on that category page. Now Widget Logic lets me control the category page visibility part. WP Page Views counts page visits and keeps that score in a meta_value with meta_key views. So I expected to be able to use Query Posts to do the rest of the math by giving it the following settings (apart from the obvious title and stuff):

    showposts: 5
    order: DESC
    orderby: meta_value
    meta_key: views
    category_name: jazz
    wp_reset_query: checked

    Widget Logic: is_category(‘jazz’)

    Now when viewing the ‘jazz’ category page, I see a list of 5 posts that are all from that category. So far so good. But when I check the meta values for key ‘views’ in those posts, they are not in descending meta value order. They appear not even ordered at all.

    When I select orderby: date , the order is indeed by date. Further, caller_get_posts:checked does not seem to make any difference (sticky post do not go on top, even when not checked)

    I also tested by setting meta_compare (larger than) and meta_value (some average number) to see if I could at least filter out the lesser viewed posts but this did not seem to work either.

    Note: I am using the Hybrid News child theme.

    Thanks!

    http://wordpress.org/extend/plugins/query-posts/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Rolf Allard van Hagen

    (@ravanh)

    I also noticed that meta_compare option does not always get saved.

    When setting != , = or > there is no problem (except > seems to behave like < ) with saving but when trying one of the other options, after saving the widget, that option comes up blank again…

    Weird stuff happening here!

    its due to a bug on the code. he’s trying to strip tags from the settings when they are passed back to save. The less than sign in ‘<‘ and ‘<=’ is being stripped out.

    You can change line 261 in query-posts.php to the following to resolve the immediate issue:

    $instance[‘meta_compare’] = $new_instance[‘meta_compare’];

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Query Posts] orderby meta_value and meta_compare problems’ is closed to new replies.