Home › Forums › Front-end Issues › Echo all available the_field › Reply To: Echo all available the_field
One step simpler would be to put each of the field names into an array and then loop through using your code above:
$my_fields = array('position','dimension','color','weight','etc');
foreach ( $my_fields as $my_field ) {
if ( the_field( $my_field ) ) echo the_field( $my_field );
}
If you want to go one step more complicated, you could try automatically building the array of field names by querying all the fields within a particular field group.
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.