ACF checkbox array is returning numbers, not labels [closed]

ACF is actually doing what it should – storing a numerical array of selected values. If you want the label you can levy get_field_object, which returns information about the custom field (rather than the value of it for the given post). $field_obj = get_field_object( ‘nav_widget_platforms’ ); $platforms = get_field( ‘nav_widget_platforms’ ); foreach ( $platforms as … Read more

Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis

For anyone with the same problem, here’s the answer. I finally figured it out. // Display Profile Sidebar ACF add_action(‘genesis_sidebar’, ’employee_title’); function profile_photo() { if ( is_singular(‘profile’) && genesis_get_custom_field(’employee_title’) ) echo ‘<div id=”employee-title”> ‘. genesis_get_custom_field(’employee_title’) .'</div>’; } This is the the hook location in Genesis where the custom field data needs to output to: genesis_sidebar. … Read more

prevent HTML output if custom field is empty [closed]

Just a simple php if to check the contents of the field before outputting markup. <?php if( $second_comment = get_field(‘second_content_block’) ){ ?> <div class=”page-content-text-additional”> <?php echo do_shortcode(“[vr_jsp] $second_comment [/vr_jsp]”); ?> </div> <?php } ?> You can eliminate the need for adding the class via js using the same method. Some friendly advice- spending a day … Read more

Included posts on a page searchable

The problem is that by default WordPress only looks in the title and content field. As you build your pages from multiple pieces of external post types the default query doesn’t find those parts. Before we go any further I want you to know that this is going to be quite involved as you need … Read more

Advanced Custom Fields – Relationship post foreach query

Use the old method of adding the relationship field -> Post Object <?php while (have_posts()) : the_post(); ?> <div class=”entry-content”> <h1 class=”content-headline”>Package: <?php the_title(); ?></h1> </div> <div class=”package-description” style=”padding:15px 10px;background:white;”> <?php the_content(); ?> </div> <?php $posts = get_field(‘package_items’); if( $posts ): ?> <ul> <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) … Read more

Insert a field with PREG_REPLACE – strange behaviour

You need to use get_field function here instead of the_field. function wrapImagesInDiv($content) { if ( in_category( ‘projects’ ) ) { $pattern = ‘/(<img[^>]*class=\”([^>]*?)\”[^>]*>)/i’; $replacement=” <div class=”owl-wrapper”> <div class=”owl-item $2″> “.get_field(‘description’).’ $1 </div> </div>’; $content = preg_replace($pattern, $replacement, $content); } return $content; } add_filter(‘the_content’, ‘wrapImagesInDiv’); Function get_field returns the value but the_field prints the value.