Home › Forums › Front-end Issues › Help Please: Links in the category of custom fields › Reply To: Help Please: Links in the category of custom fields
Hi @wilfredo123
The use of get_term_link and passing in the term item should do the trick for you for getting the link.
You can try the code below… I setup a counter in the test code to be sure not to have a comma at the end of your list. It should display as shown in your image, but please test it for bugs.
Hope this helps! Let me know.
<?php
$empresa_terms = get_field( 'empresa' );
if ( $empresa_terms ) {
$total = count( $empresa_terms );
$count = 1;
echo 'Places: ';
foreach ( $empresa_terms as $empresa_term ) {
echo '<a href="' . get_term_link( $empresa_term ) . '">';
echo $empresa_term->name;
echo '</a>';
if ( $count < $total ) {
echo ', ';
}
$count++;
}
}
?>
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.