jeudi 5 février 2015

Sorting posts by ACF field


I am trying to sort posts by the 'prempost' ACF field, but it's not working (just shows default order). Can anyone see where I'm going wrong? ACF support suggested that I use http_build_query, which I've done below, but still no cigar:/



<?php
$meta_query = array(
'relation' => 'OR',
array(
'key' => 'prempost',
'compare' => 'IN'
),
array(
'key' => 'prempost',
'compare' => 'NOT IN'
)
);

$args = array(
'meta_query' => $meta_query,
'orderby' => 'meta_value',
'meta_key' => 'prempost',
'order' => 'ASC',
);?>

<?php $new_args = http_build_query($args); ?>
<?php $posts = query_posts($query_string.'&'.$new_args); ?>

//begin loop
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>




Aucun commentaire:

Enregistrer un commentaire