WordPress.org

Ready to get started?Download WordPress

Forums

order by serialized meta value (4 posts)

  1. aseroh
    Member
    Posted 2 years ago #

    I have problem with this site.

    http://wordpress.stackexchange.com/questions/15839/wordpress-how-to-sort-by-meta-value

    I need help.I tried the answers below but it is still not working.

  2. esmi
    Forum Moderator
    Posted 2 years ago #

  3. aseroh
    Member
    Posted 2 years ago #

    Thanks for the reply.

    I tried it but it's not working but I think there something missing or wrong in my code.

    Let use the code from the link i gave.
    This is the meta value
    a:6:{s:5:"width";s:3:"580";s:6:"price";s:3:"99"

    So the code is

    global $query_string;
    parse_str( $query_string, $my_query );
    $my_query['meta_query'] = array(
        array(
             'key' => 'price',
             'value' => 0,
             'type' => 'SIGNED',
             'compare' => '>=',
        )
    );
    $my_query['orderby'] = '3';
    $my_query['order'] = 'ASC';
    query_posts( $my_query );

    Actually I'm sure if the code below is right.

    $my_query['orderby'] = '3';

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    No - $my_query['orderby'] = '3'; is not right. See http://codex.wordpress.org/Function_Reference/WP_Query

Topic Closed

This topic has been closed to new replies.

About this Topic