Support

Account

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>';
    }