Showing posts with label Order By Custom Field Using Meta Key In Wordpress. Show all posts
Showing posts with label Order By Custom Field Using Meta Key In Wordpress. Show all posts

Monday, 27 July 2015

Order By Custom Field Using Meta Key In Wordpress

Hello

Order By Custom Field Using Meta Key In Wordpress

In some case you can to get post value using meta box in order by ascending order and descending order

<?php

$dancequery = array('post_type'=> 'dance',
'tax_query' => array(
array('taxonomy' => 'hip_hop','field' => 'id','terms' =>'hip_hop',),
),
'posts_per_page'=>12,
'post_status' => 'publish',
'paged' => $paged ,
'meta_key' => 'price',
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
query_posts( $dancequery );

?>

if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>




  • check this type code. price yon can add your meta key create in post.
    i am also give example with taxonomy you can get value form particular taxonomy and particular
    meta key order by i have meta key price.

    it's working proper check out.