admin管理员组文章数量:1023803
I have a bootstrap 4 card columns masonry like grid. I want to show six posts form my articles and I'm using a custom query to retrieve the posts. All works fine, but the posts aren't showed with the order I want. I don't know if it's because the card columns bootstrap settings or because the wordpress query. Is there a simple way to order the loaded posts with a custom order?
here is the example of my wp query
<?php
$clients = ['199','168','86','291','113','229'];
$portfolio = new WP_Query(array(
'post_type' => 'post',
'status' => 'published',
'category_name' => 'Portfolio',
'posts_per_page'=> 6,
'post__in' => $clients
));
?>
<div class="card-columns">
<?php if( $portfolio->have_posts() ): while( $portfolio->have_posts() ): $portfolio->the_post(); ?>
<div class="card hide">
<a href="<?php the_permalink(); ?>">
<img class="card-img-top w-100" src="<?php the_post_thumbnail_url('full'); ?>" id="case-studies">
<div class="overlay"><h4 class="text-center" id="client-name"><?php the_title(); ?></h4></div>
</a>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
</div>
I have a bootstrap 4 card columns masonry like grid. I want to show six posts form my articles and I'm using a custom query to retrieve the posts. All works fine, but the posts aren't showed with the order I want. I don't know if it's because the card columns bootstrap settings or because the wordpress query. Is there a simple way to order the loaded posts with a custom order?
here is the example of my wp query
<?php
$clients = ['199','168','86','291','113','229'];
$portfolio = new WP_Query(array(
'post_type' => 'post',
'status' => 'published',
'category_name' => 'Portfolio',
'posts_per_page'=> 6,
'post__in' => $clients
));
?>
<div class="card-columns">
<?php if( $portfolio->have_posts() ): while( $portfolio->have_posts() ): $portfolio->the_post(); ?>
<div class="card hide">
<a href="<?php the_permalink(); ?>">
<img class="card-img-top w-100" src="<?php the_post_thumbnail_url('full'); ?>" id="case-studies">
<div class="overlay"><h4 class="text-center" id="client-name"><?php the_title(); ?></h4></div>
</a>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
</div>
Share
Improve this question
asked Apr 16, 2019 at 15:11
gogoDollgogoDoll
11 bronze badge
3
|
1 Answer
Reset to default 0Take a look at the order
and orderby
parameters of WP_Query.
I have a bootstrap 4 card columns masonry like grid. I want to show six posts form my articles and I'm using a custom query to retrieve the posts. All works fine, but the posts aren't showed with the order I want. I don't know if it's because the card columns bootstrap settings or because the wordpress query. Is there a simple way to order the loaded posts with a custom order?
here is the example of my wp query
<?php
$clients = ['199','168','86','291','113','229'];
$portfolio = new WP_Query(array(
'post_type' => 'post',
'status' => 'published',
'category_name' => 'Portfolio',
'posts_per_page'=> 6,
'post__in' => $clients
));
?>
<div class="card-columns">
<?php if( $portfolio->have_posts() ): while( $portfolio->have_posts() ): $portfolio->the_post(); ?>
<div class="card hide">
<a href="<?php the_permalink(); ?>">
<img class="card-img-top w-100" src="<?php the_post_thumbnail_url('full'); ?>" id="case-studies">
<div class="overlay"><h4 class="text-center" id="client-name"><?php the_title(); ?></h4></div>
</a>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
</div>
I have a bootstrap 4 card columns masonry like grid. I want to show six posts form my articles and I'm using a custom query to retrieve the posts. All works fine, but the posts aren't showed with the order I want. I don't know if it's because the card columns bootstrap settings or because the wordpress query. Is there a simple way to order the loaded posts with a custom order?
here is the example of my wp query
<?php
$clients = ['199','168','86','291','113','229'];
$portfolio = new WP_Query(array(
'post_type' => 'post',
'status' => 'published',
'category_name' => 'Portfolio',
'posts_per_page'=> 6,
'post__in' => $clients
));
?>
<div class="card-columns">
<?php if( $portfolio->have_posts() ): while( $portfolio->have_posts() ): $portfolio->the_post(); ?>
<div class="card hide">
<a href="<?php the_permalink(); ?>">
<img class="card-img-top w-100" src="<?php the_post_thumbnail_url('full'); ?>" id="case-studies">
<div class="overlay"><h4 class="text-center" id="client-name"><?php the_title(); ?></h4></div>
</a>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
</div>
Share
Improve this question
asked Apr 16, 2019 at 15:11
gogoDollgogoDoll
11 bronze badge
3
-
1
Take a look at the
order
andorderby
parameters ofWP_Query
. codex.wordpress/Class_Reference/… – MikeNGarrett Commented Apr 16, 2019 at 15:17 - "I don't know if it's because the card columns bootstrap settings or because the wordpress query" figure that out and then you will know which path to investigate on sorting – RiddleMeThis Commented Apr 16, 2019 at 15:18
-
1
@MikeNGarrett Solved by using the
orderby
param inWP_Query()
Thanks for the suggestion – gogoDoll Commented Apr 16, 2019 at 16:13
1 Answer
Reset to default 0Take a look at the order
and orderby
parameters of WP_Query.
本文标签: wp queryOrder posts inside bootstrap card columns
版权声明:本文标题:wp query - Order posts inside bootstrap card columns 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745583031a2157420.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
order
andorderby
parameters ofWP_Query
. codex.wordpress/Class_Reference/… – MikeNGarrett Commented Apr 16, 2019 at 15:17orderby
param inWP_Query()
Thanks for the suggestion – gogoDoll Commented Apr 16, 2019 at 16:13