Hot answers tagged

3

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() ) ) { ...


2

like people said there is probably a lot of things wrong with your code. so lets start line by line. whether this is a plugin or a file inside a theme include_once( 'acf.php' ); im assuming you have that file in the same directory as the current file otherwise you are including it wrong. this define( 'ACF_LITE', true ); needs to happen before it is every ...


1

At first - do not use extract. It's very bad code style and is also depracated in core. Every time your foreach loop run, you override content of $output because you assign to this variable new content. What you want is to concatenate new list item with existing ones. This can be done using concatening assignment operator: $output .= '<li ...


1

For every meta value saved there is a second row prefixed with _ that stores what field definition this value refers to. Do not delete it. Your example additionally is a repeater which makes it more complex but the docs has a nice explanation: $ParentName_$RowNumber_$ChildName So you have a repeater field called carousel which has a subfield called ...


1

You can get both with an OR meta_query that also checks if the key does not exist: 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'event_date', 'compare' => 'NOT EXISTS', ), array( 'key' => 'event_date', 'value' => date("Ymd", time()), 'compare' => '>', ), ), ...



Only top voted, non community-wiki answers of a minimum length are eligible