Support

Account

Home Forums General Issues ACF data not showing in the front without a manual post update.

Solving

ACF data not showing in the front without a manual post update.

  • Ok, so I am having a very simple problem that I have spent hours trying to debug and hope someone can help.

    I have
    Post type – Location (bidirectional to company using a relationship box)
    Post type – Company (bidirectional to location using a relationship box)

    I imported custom data from csv using an import plugin. I am using acf extended to define the bidirectional relationship. I imported the location field using a relationship box into the company post type. I also have a company field in location post type which should auto update based on bidirectional relationship.

    In the frontend, I have two templates location.php and company.php, the company template works fine and displays the location. However until, I open the company post type and update the post manually, the location would simply not display.

    The solutions I have tried so far,

    Update all posts using the WP Cli
    sudo wp post update $(wp post list –post_type=’company’ –format=ids –posts_per_page=4000) –post_status=publish –allow-root

    This updates the post but the data does not appear in the front.

    Use a custom function without much success.

    // Retrieve all pages
    $my_posts = get_posts(array(
    ‘post_type’ => ‘company’, // Post Type: page
    ‘posts_per_page’ => -1,
    ));

    foreach($my_posts as $key => $my_post) {
    $meta_values = get_post_meta( $my_post->ID);

    foreach($meta_values as $meta_key => $meta_value) {
    update_field($meta_key, $meta_value[0], $my_post->ID);
    echo $my_post->ID ,”</br>” ;
    }
    }

    Stackoverflow thread with same issues and no answer
    https://stackoverflow.com/questions/41158413/wp-all-import-with-advanced-custom-fields-does-not-display-correctly-until-afte

  • You will need to create an action or filter that runs during the import, see this reference https://www.wpallimport.com/documentation/advanced/action-reference/ I’m not sure what filter to tell you to use here, but I think it would need to be “pmxi_saved_post”.

    WPAI does not call update_field() when importing ACF fields, it calls update_post_meta() directly, so anything added by the plugin that creates the bidirectional fields will be bypassed.

    So what you need to do is use the correct action/filter for WPAI and in your filter or action get the relationship field value and use update_field() to update that value which should cause the acf add on to perform it’s own actions to create the bidirectional entries needed.

  • Hi both, I am experiencing the same issue in a slightly different scenario. I believe that the error lies within the same core problem.

    I am generating posts using automation tools to populate and create Custom Posts that contain ACF fields. However, even though these posts are created a manual update is needed for them to shown on the front end ( Where I am using Oxygen, Repeater, ACF and FacetWP)

    I have tried updating the partnered variables like variable & _variable. I have gone so far as to try to utilise uncanny automaton to update the post once launched in order to allow those variables to show up to no avail.

    Is there any progress on a high level on this problem? or could either of you point me in another direction.

    @evilopinions @hube2

  • I have the same issue,

    New site. ACF is installed and my custom fields are imported from the themes acf-json folder.

    The ACF fields were exported from one site and imported into the other.

    I exported my pages from the old site, imported (standard WP Import) them into the new one.

    When I view the page on the backend I can see everything displaying correctly but nothing shows until I update the page.

    I don’t know if it helps, but none of the imported pages have content in the main body, they are 100% ACF pages.

  • Hi everyone,

    I am having the same issue. All import is good at backend but the shortcode info on front end is not showing if i not update each post manually :S

    I am importing woocommerce products with meta value, nothing all.

    Thank you

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

You must be logged in to reply to this topic.