My Query is getting the wrong data

$the_args = array ( ‘post_type’ => ‘jobs’, the_field(‘job_category’) ); The trouble here is that the_field( ‘job_category’ ) prints data, so using it to build an array is pretty much useless. You’re left with literally post_type = job. However, the real problem is that you actually need to grab the category options, not the posts that … Read more

the_post_thumbnail unless video id is added

I think all you need is this: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> if (get_field(‘channel’) == ‘Youtube’) { echo get_field(‘youtube_video_id’); } elseif (get_field(‘channel’) == ‘Vimeo’) { echo get_field(‘vimeo_video_id’); } elseif ( has_post_thumbnail()) { the_post_thumbnail(); } That should use a Youtube video, then a Vimeo video, then the thumbnail, … Read more

Copying custom field value in to title

Try this: add_action(‘init’, ‘replace_title_logic’); function replace_title_logic() { add_filter(‘wp_insert_post_data’, ‘replace_title_before_update’, 20, 2); add_action(‘wp_insert_post’, ‘replace_title_after_save’, 20, 2); add_filter(‘wp_insert_post_empty_content’, ‘allow_empty_content_for_listing’, 20 , 2); } function replace_title_before_update( $data, $postarr ) { if ( is_int($postarr[‘ID’]) && ($data[‘post_type’] == ‘listing’) ) { $custom = get_post_meta($postarr[‘ID’], ‘ref._nr.’, true ); if ( $custom && ( $custom != $data[‘post_title’] ) ) $data[‘post_title’] = $custom; … Read more

Advanced Custom Field User Help URL

I have this exact thing working on a current project. Here’s the code: <div class=”photo-feature” style=”background: url(<?php the_field(‘the-image’, $page->ID) ;?>) no-repeat center center; “></div> Keep in mind a couple of things: You may need to use $post->ID or $page->ID if you’re using a custom query. Make sure you’re not overriding your background CSS anywhere else … Read more

Advanced Custom Fields repeter field expiration

Possibly better than strtotime, as you already know the date format would be date_create_from_format(). Something like: $course_start = date_create_from_format(‘dmY’,$row[‘start_date’]); if ($course_start > date(‘dmY’)){ echo ‘<tr>’; echo ‘<td>’ . $i . ‘</td>’; echo ‘<td>’ . $row[‘start_date’] ; // Check, if “end_date” field is not empty if( $row[‘end_date’]) { echo ‘ – ‘ . $row[‘end_date’] . ‘</td>’; … Read more