I have been at this for two days with no luck and I hoping someone can help. What I am trying to accomplish is very simple, yet I am missing something.
I have a several custom fields that appear on the WooCommerce product category edit screen (where you add/edit product categories), which then display the output on the archive-product.php category template. I have managed to display all of my custom fields on the front-end product category archives with the exception of the taxonomy custom field.
What I am trying to do is have the user choose from multiple product categories, then on the front-end just display the links to other product categories, a simple text link.
The unsuccessful code I am using for this is:
<?php
$terms = get_field('quick_links');
if( $terms ): ?>
<ul>
<?php foreach( $terms as $term ): ?>
<a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?></a>
<?php endforeach; ?>
</ul>
<?php endif; ?>
I tested the above code out on a regular page template and it works as I wanted. However, I cannot get it to display on my product category archive template.
I only was able to display the OTHER custom fields I have, with the following code:
<?php
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
echo '<div class="top-content-block">';
the_field('top_content_block', $taxonomy . '_' . $term_id);
echo '</div>';
echo '<div class="center-content-block">';
the_field('center_content_block', $taxonomy . '_' . $term_id);
echo '</div>';
echo '<div class="featured-product-block">';
the_field('featured_products', $taxonomy . '_' . $term_id);
echo '</div>';
?>
Does anyone have any suggestions? I am at a loss.
Thanks