Support » Plugin: Custom Field Suite » How to Display All Saved Meta Data

  • Resolved starapple

    (@starapple)


    Hi Matt,

    I’m trying to find out how to display the saved data in a list as is the output of WP’s the_meta();

    I’m using the_meta(); to display a post and thought it’d have printed labels such as “First Name: Tony”, rather than the meta names used, “first_name: Tony”.

    Is there a function similar to the_meta(), which prints the labels rather than the meta names? Or is there a way to loop through CFS()->get() and
    CFS()->get_field_info()?

    I have 21 fields. Do I face the prospect of doing it line by line like:

    $loop = CFS()->get();
    $props = CFS()->get_field_info();
    echo '<br>' . $props['first_name']['label'] .':'.$loop['first_name'] .' '. $loop['last_name'];
    echo '<br>' . $props['street_address']['label'] .':'.$loop['street_address'];
    echo '<br>' . $props['state']['label'] .':'.$loop['state'];

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Matt Gibbs

    (@mgibbs189)

    No, just loop through $props:

    $vals = CFS()->get();
    $props = CFS()->get_field_info();
    foreach ( $props as $field_name => $prop ) {
        echo '<br>' . $prop['label'] . ':'. $vals[ $field_name ];
    }
    
    • This reply was modified 2 years, 2 months ago by  Matt Gibbs.

    Thanks @mgibbs189. I should have been able to figure that out but didn’t.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Display All Saved Meta Data’ is closed to new replies.