functions – Wp-query Order By problem
Question
I’m trying to sort a query according to the order they write it in but it takes an order by ID.
The variable $idpaginas prints: 20659,20626,20585,20616,18464,19748,19991,18520,20588,21268,18753,20556,21277,18829,18551,21132
But after the query, it prints: 18520,18520,18551,18753,18829…..
function LoopMode($atts, $output = null, $my_query = null, $query_args = null) {
// Params extraction
extract(shortcode_atts(array(
'idpaginas' => '',
'style' => '',
), $atts));
$query_args = array(
'post_status' => 'publish',
'post__in' => explode( ",", $idpaginas ),
'posts_per_page' => -1,
'post_type' => 'page',
'order_by' => 'post__in',
'order' => 'ASC',
);
if(empty($style)){ $style="2"; }
// Run query
$my_query = new WP_Query( $query_args );
//$output="";
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="cluster-box col-<?php echo $style; ?>">
<a href="<?php the_permalink() ?>" class="cluster-mcl-link">
<div class="mcl-cluster">
<div class="mcl-cluster-img" style="background-image:url(<?php the_post_thumbnail_url(); ?>);">
<div class="mcl-cluster-title"><h3><?php the_title(); ?></h3></div>
</div>
</div>
</a>
</div>
<?php endwhile;
$my_query = null; $my_query = $temp;
$output = ob_get_contents();
ob_end_clean();
wp_reset_postdata();
return $output;
}
add_shortcode('cluster', 'LoopMode');
I have tried to remove args “order_by” and “order” values but it still continues to order it as he wants.
Thanks!
0
1 year
2021-11-24T08:31:31-05:00
2021-11-24T08:31:31-05:00 0 Answers
0 views
0
Leave an answer