I have to echo out all categories with posts that are inside my custom post type that ia have created. I have currently three categories and i need it because i might add another category and thats why i dont have to dive in to coding to display another query.
Style:
- Category title
-- category post title, content etc.
- Category2 title
-- Category2 post contents
My current code looks like that
<?php
$args=array(
'post_type' => 'edasimja'
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="col-sm-4">
<?php $c = get_the_category(); ?>
<?php echo $c[0]->cat_name; ?>
<h2><?php the_title(); ?></h2>
<?php the_field('eli'); ?>
</div>
<?php
endwhile;
}
wp_reset_query();
?>
This code querys every single post with its cat name separately, but i need a column with every category. I cant seem to achieve that.
Can someone point me to the right direction?