Forum Replies Created

  • I usually use the “message” field as way to add instructions and other info as needed within the editor itself.

  • I just encountered this very issue as well… We have a page builder (Flexible Content) where each layout loads in a cloned component. A sync was performed (with all syncable fields checked), at which point it seems the page builder was “expanded” into its component fields…


    Not all of the fields were correct 🙁 At least one of the components was missing a field (and that field also wasn’t showing on the front-end). This is how we discovered there was an issue.

    I noticed the mod date on the JSON of the page builder was way different from what it should have been and I assumed that someone had messed with it in the admin. I pulled a backup from the day before and that JSON file looked correct. I was able to update the timestamp on my local version of the JSON and pushed to the site, performed a sync, and the missing field(s) was restored.

  • I’m looking to do something similar, but I’m focusing on the use case that the user will enter either a product name or a SKU. Name is the title field, so that will come back in results by default. If they enter a SKU, that’s an ACF field.

    So, what I’m doing is firing a query against the default $args array, and if it contains posts, I return that array as-is.

    If it doesn’t return any posts, then I overwrite $args with a new array that looks at my custom field, and also removes the ‘s’ argument to kill the default search functionality.

    It seems to be working pretty well given this use case. I tried to combine both conditions using post__in, but you still wind up with the situation where you have the ‘s’ param searching in title and content, and creating a default ‘AND’ relationship with the meta_query. Also, if the title/content search succeeds, it never looks at the SKU, but that’s not an issue in my case since the SKU value is somewhat human un-readable and would make for a pretty lousy product title.

    My code is below for reference:

    function my_related_query($args, $field, $post_id) {
    	if ($args['s'] == '') {
    		// nothing passed in, so just return $args as it stands and get out of here.
    		return $args;
    	// check for posts using $args
    	$result = new WP_Query($args);
    	if ($result->found_posts == 0) {
    		// no posts found for the query, so it might be a sku... take a look there?
    		$args['meta_query'] = array(
    				'key' => 'sku',
    				'value' => $args['s'],
    				'compare' => 'like'
    		$args['posts_per_page'] = -1;
    		$args['s'] = '';
    	return $args;
    add_filter('acf/fields/relationship/query/name=related', 'my_related_query', 10, 3);
  • So, I wound up using save_post vs acf/update_value, and that seems to work.

    Here’s my final working function for anyone else that’s looking to extract lat/lon out of the map field:

    function rhm_update_latlon($post_id, $post, $update) {
    	$map = get_post_meta($post_id, 'map_location', true);
    	if (!empty($map)) {
    	    update_post_meta( $post_id, 'loc_lat', $map['lat'] );
    	    update_post_meta( $post_id, 'loc_lng', $map['lng'] );
    add_action('save_post', 'rhm_update_latlon', 90, 3);

    That said, it would still be great to see the map_location data stored separately as individual fields (even better would be to break out the individual address components) so they could all be queried and extracted as needed.

  • Update.. It looks like the code I’m using is also blowing out other loc_lat and loc_lng post_meta on save, so if I update one location, the others all get wiped out 🙁

  • You could check to see if the date has changed from the last event displayed, and if it has, then you display the date; otherwise you just display the event.. something along the lines of:

    // initialize the last displayed date.. since this is before the loop, we'll just make it an empty string
    $lastDate = '';
    while ($schedule_query->have_posts()) : $schedule_query->the_post(); ?>
    <?php // now that we're in the loop, start outputting events ?>
    <div class="screening">
    						<h2><strong><?php $date = DateTime::createFromFormat('Ymd', get_field('screening_date'));
    // now that we have the event's date, see if it matches the last date displayed.. if not, we'll update $lastDate with the event's date and display it
    if ($date != $lastDate) {
    $lastDate = $date;
    echo $date->format('F d, Y'); ?>, </strong></h2>
  • Having this same exact issue, although it’s good to see that the order in which you do things helps to alleviate it. Working w/ Support now to try to get it resolved.

    Happens with Flexible Content Fields as well.

  • I just ran into this issue whereby filtering a post_object’s query wasn’t taking, but it looks like when a post_object’s type is ‘page’, ACF is effectively firing get_pages vs. creating a new WP_Query, so the args are all different.

    So, running this choked:

    	$args['post_parent'] = $parent->ID;
    	$args['orderby'] = 'menu_order';

    While running this works great:

    	$args['child_of'] = $parent->ID;
    	$args['sort_column'] = 'menu_order';

    Hopefully this will help anyone else who’s wondering why this isn’t working properly.

Viewing 9 posts - 1 through 9 (of 9 total)