Generate Advanced Custom Fields box in custom admin menu page

Interesting exercise, a one page plugin that believes it deserves a first level menu page is wrong, IMO. I use the same technique with Jetpack. To create sub-pages in the Options Page add-on, read the documentation. The logic of this menu/sub-menu swapping is: Add multiple ACF Options Pages Create our menu first level page Remove … Read more

Returning all radio button options when using Advanced Custom Fields

Check out this page in order to discover your field key for your radio button: http://www.advancedcustomfields.com/docs/functions/get_field_object/ Next, insert this code where you are grabbing your field values: <?php $key = ‘your_fieldkey_here’; $field = get_field_object($key); if ($field) { foreach ($field[‘choices’] as $key => $value) { echo (‘KEY : ‘ . $key); echo (‘<br />’); echo (‘VALUE … Read more

Adding a body class with ACF

Hook into the body_class filter and add your field there. It might be better to get the ID from get_queried_object_id() instead of get_the_ID(). add_filter( ‘body_class’, ‘wpse_20160118__body_class’ ); function wpse_20160118__body_class( $classes ) { if ( $package_colour = get_field( ‘package_colour’, get_queried_object_id() ) ) { $package_colour = esc_attr( trim( $package_colour ) ); $classes[] = $package_colour; } return $classes; … Read more

If Custom Field is empty don’t display div

Try this: <?php $business_services = get_field( “services_for_businesses” ); //etc… ?> <div class=”section-title”>Services for Individuals</div> <div class=”section-text”> <?php the_field(‘services_for_individuals’) ?> </div> <?php if ( $business_services ) : ?> <div class=”section-title-business”>Services for Businesses</div> <div class=”section-text”> <?php echo $business_services; ?> </div> </div> <?php endif; ?> </div> Further abstract the code to meet your needs if you have more … Read more

ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format

There should not be any need to do this. Even if an ACF Field is using ‘return_format’ => ‘m/d/Y g:i a’, The post_meta value is in YYYY-MM-DD 00:00:00 format. $date_now = date(‘Y-m-d’); $args = [ ‘meta_key’=>’the_date’, ‘meta_value’=>$date_now.’ 00:00:00′, ‘meta_compare’=>’>=’, ]; $query = new WP_Query( $args ); Edit: I’ve noticed some discrepancies in this, the value … Read more