Support » Fixing WordPress » Sort post by custom field alphabetically

  • Hi ther everybody.
    I have searched all arround for a awnser to this. Even thoug i found some clues using another kind of loop structure, directly from db i didn’t get it

    I have this code:

    <?php $argsvs = array(
           	      		'post_type' => 'imovel-para-venda',
           	      		'meta_key' => 'wpcf-imovel-preco',
           	      		'posts_per_page' => 0,
           	      		 'oderby' => 'meta_value',
           	      		 'order' => 'DESC'
    $loop = new WP_Query( $argsvs );
    while ( $loop->have_posts() ) : $loop->the_post();

    and so on

    the thing is that the custom field wpcf-imovel-preco was created using the plugin Types, and it is a text field. Usually, it is used to put numbers, but sometimes filled with words too.

    Anyone could help me find the way to order my loop by that custom field? Alphabetically, i think?

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’m still looking, and i think probably i will do it with Meta_query but i couldn’t find how to do it yet

    The good news is that a nice stackoverflow user showed me that I was missin and ‘r’ in ‘orderby’…..
    the bad news is that
    the values are like: 100.000.00 and 120.000,00….. but 1.200.000,00 apeears before 100.000,00 , any idea how to fix this?

    Moderator Andrew Nevins


    What number is 1.200.000,00 supposed to represent?

    My post was blank at one moment because I retracted my comment.

    oh, dude, i loved your awnser!
    (lol, it is in blank here )

    ok, it apears now!
    well 1.200.000,00 is 1,200,000.00 in brazilian notation
    we use . instead of , and , instead of .

    1.200.000,00 = 1.2 milion ^^

    no prob for the blank post hehehe, any ideas that could help me do that? (thanks for awnsering, btw!)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Sort post by custom field alphabetically’ is closed to new replies.