samedi 18 avril 2015

Returning the name of a category in Wordpress

I have a loop for a custom post type an all is working well, except I cannot return the actual category name that the post has assigned to it.


I have the following code:



<?php
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'portfolio',
'orderby' => 'menu_order',
'order' => 'ASC'
));


if($posts) {
foreach($posts as $post) {
setup_postdata( $post );
?>
<div>
<div class="mix <?php get_cat_name( ); ?>" ><img src="<?php the_field('portfolio_image'); ?>" alt=""></div> <!-- ACF -->
</div>
<?php
}
}
wp_reset_postdata();
?>


This is just one of the WP Codex functions I have tried including tring all with echo. I imagine my problem is something else? Many thanks in Advance.


Aucun commentaire:

Enregistrer un commentaire