WordPress.org

Support

Support » Plugins and Hacks » Sort post by custom field alphabetically

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?

  • The topic ‘Sort post by custom field alphabetically’ is closed to new replies.