Home › Forums › Front-end Issues › Displaying Fields from Post Category or Subcategory › Reply To: Displaying Fields from Post Category or Subcategory
My real-world application needed repeater fields, so here are repeater fields from a category page:
$current_category = single_cat_title("", false);
$term_id = get_queried_object_id($current_category);
if(get_field('state_links', 'category_' . $term_id))
{
echo '<h2><span>';
echo single_cat_title() . ' FFA Links';
echo '</span></h2>';
echo '<ul id="double" class="state">';
while(has_sub_field('state_links', 'category_' . $term_id))
{
echo '<li class="state"><a href="' . get_sub_field('state_link', 'category_' . $term_id) . '" target="_blank">' . get_sub_field('state_link_title', 'category_' . $term_id) . '</a></li>';
}
echo '</ul>';
}
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.