0

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>
3
  • 1
    Take a look at the order and orderby parameters of WP_Query. codex.wordpress.org/Class_Reference/… 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 Commented Apr 16, 2019 at 15:18
  • 1
    @MikeNGarrett Solved by using the orderby param in WP_Query() Thanks for the suggestion
    – gogoDoll
    Commented Apr 16, 2019 at 16:13

1 Answer 1

0

Take a look at the order and orderby parameters of WP_Query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.