Loop through ACF to display all possible field values?

I am creating a site that uses an isotope to filter messages on a page.

I use the advanced custom fields ( http://www.advancedcustomfields.com/ ) and created a section where the user can set the field for "Project Difficulty".

I am trying to do everything possible to create a list of links that the user can click to sort (using the isotope). I successfully work using "tags", but I don’t want to mark each project with a level of complexity, I want the user to select it when creating a message in the ACF drop-down list.

To successfully retrieve and display the tag list as links, I used this code:

<?php
$tags = get_tags();
  $html = '<div class="post_tags">';
  foreach ( $tags as $tag ) {
  $tag_link = get_tag_link( $tag->term_id );

  $html .= "<a data-filter=.{$tag->name} title='{$tag->name} Tag' class='{$tag->slug}'>";
  $html .= "{$tag->name}</a>";
}
$html .= '</div>';
echo $html; 
?>

, ACF, :

  <?php
   $fields = get_fields();
   $html = '<div class="post_tags">';
  foreach ( $fields as $field ) {
     $tag_link = get_fields( $field->task_difficulty );

    $html .= "<a data-filter=.{$field->name} title='{$field->name} Tag' class='{$field->slug}'>";
    $html .= "{$field->name}</a>";
  }
   $html .= '</div>';
   echo $html;
  ?>

:

<a data-filter="." title=" Tag" class=""></a>

. , . , ?

+4
1

-, , , :

        // must add field key of the field you want
        $field_key = "field_52a087a80a4c6";
        $field = get_field_object($field_key);

        if( $field )
        {
            echo '<div class="acf-task-difficulty-values">';
                foreach( $field['choices'] as $k => $v )
                {
                    echo '<a data-filter=.'.$k.' onclick="return false;">' . $v . '</a>';
                }
            echo '</div>';
        }

CSS.

+9

All Articles