Minimising number of queries on a page when using Advanced Custom Fields

Performance optimization doesn’t really work in vaccum, it takes hands-on profiling an looking for actual bottle necks (which often turn out to be different from perceived ones). But it general there are several approaches to the need of lots of database data: Optimize fetching from database, for example by concatenating multiple requests into retrieving single … Read more

Show custom field from custom taxanomy term on custom post type

Use the get_the_terms function instead so you can build the list manually and access the term_id for each term. $terms = get_the_terms( $post->ID, ‘taxanomy-name’ ); echo ‘<ul>’; foreach( $terms as $term ): echo ‘<li>’; echo $term->name; the_field( ‘custom-field-name’, ‘taxanomy-name_’ . $term->term_id ); echo ‘</li>’; endforeach; echo ‘</ul>’;

Display HTML only if Custom Field has a Value

You can use the “get_sub_field” to test for the subfields. If nothing is returned and they are empty, it won’t show the content associated with the if statement. <?php if ( get_field(‘ingredients-list’) ) { echo ‘<ul class=”ingredientsList”>’; while ( has_sub_field(‘ingredients-list’) ) { echo ‘<li class=”ingredient” itemprop=”ingredients”>’; echo ‘<label for=””>’ . get_sub_field(‘quantity’) . ‘&nbsp; ‘; if … Read more

How to Display ACF Relationship Custom Field as Link to Specific Custom Post?

Finaly, I make this working. I put this in my template: <?php $contacts = get_field(‘list_supplier’); ?> <?php if( $contacts ): ?> <?php foreach( $contacts as $contact ): ?> <a href=”https://wordpress.stackexchange.com/questions/118817/<?php echo get_permalink( $contact->ID ); ?>” target=”blank”><?php echo get_the_title( $contact->ID ); ?></a> <?php endforeach; ?> <?php endif; ?> And here is the filter I am using … Read more