WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Query Posts] orderby meta_value and meta_compare problems (3 posts)

  1. RavanH
    Member
    Posted 4 years ago #

    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/

  2. RavanH
    Member
    Posted 4 years ago #

    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!

  3. diablodale
    Member
    Posted 4 years ago #

    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'];

Topic Closed

This topic has been closed to new replies.

About this Topic