Home › Forums › Front-end Issues › Taxonomy Field not pulling Title or Description
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; ?>
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.