Home › Forums › General Issues › get_category_link from taxonomy addon › Reply To: get_category_link from taxonomy addon
Apologies Elliot.
Here’s all of the code that I’m using
<?php while ( have_posts() ) : the_post(); ?>
<?php if( get_field('site_cats') ): ?>
<div class="clearfix" id="site-cats">
<?php while( has_sub_field('site_cats') ): ?>
<div class="cat-block g_6 clearfix">
<div class="image">
<?php echo wp_get_attachment_image(get_sub_field('site_cat_image'), 'half-img'); ?>
</div>
<div class="details">
<h2><?php echo the_sub_field('site_cat_title'); ?></h2>
<p><?php echo the_sub_field('site_cat_description'); ?></p>
<p><?php echo the_sub_field('site_cat_link'); ?></p>
<?php
$variable = get_sub_field('site_cat_link');
$category_link = get_category_link( $variable );
?>
<a href="<?php echo esc_url( $category_link ); ?>" title=""><?php echo the_sub_field('site_cat_title'); ?></a>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php endwhile; // end of the loop. ?>
The three sub fields are working correctly i.e. title, description and link are all pulling in their fields but it’s when I then attempt to get the category ID from the site_cat_link field to then produce the category link that I’m having issues.
p.s. I use ACF in a lot of my projects now and would like to donate each time I use it – do you have such an option?
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.