
Hello,
I have a flexible content field, and I have a layout that is a ‘taxonomy’ field, where the user can select Custom Post Type Categories to display on the front-end.
I have managed to pull the link and category image, however it doesn’t seem to pull the category name or description. When I var_dump()
these, they return NULL
.
Here is my code:
<?php // portfolio categories block
if( get_row_layout() == 'portfolio_categories_layout' ):
?>
<section class="portfolio-categories">
<?php
$terms = get_sub_field('portfolio_categories_layout_select');
if( $terms ):
?>
<ul class="category-list">
<?php foreach( $terms as $term ): ?>
<li class="category-item">
<div class="image" style="background-image: url('<?php echo z_taxonomy_image_url($term); ?>');"></div>
<div class="overlay"></div>
<div class="content">
<h2><?php echo esc_html( $term->name ); ?></h2>
<?php var_dump($term->name); ?>
<?php echo esc_html( $term->description ); ?>
<?php var_dump($term->description); ?>
<a class="button button-primary" href="<?php echo esc_url( get_term_link( $term ) ); ?>">View all '<?php echo esc_html( $term->name ); ?>' posts</a>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</section>
<?php endif; ?>