Skip Navigation

[Resolved] Conflict with ACF plugin for Preview

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 2 voices.

Last updated by Christian Cox 7 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#559575

Conflict with ACF plugin for Preview. For the Access version 2.4.2, it stops the ACF fields from being displayed under the WP preview mode (&preview=true).

In earlier versions of Access tested (i.e. 2.3.1), the ACF fields show just fine with preview.

Also submitted a support request with ACF.

Thanks.

#559715

Can you tell me how you have the custom fields implemented, and how you are previewing the post? Is this a preview from a Layout Editor, or a Post editor? Is the shortcode placed in the post body, or in a Content Template?

#559739

The ACF functions (get_field, have_rows, get_sub_field, get_row_layout, etc) are all in WP Template files' PHP back-end hard coded to display custom content.

The preview is from Post Editor i.e. Edit Page.

The filter and actions to allow preview is in functions.php as follows.

function add_field_debug_preview($fields){
   $fields["debug_preview"] = "debug_preview";
   return $fields;
}
add_filter('_wp_post_revision_fields', 'add_field_debug_preview');

function add_input_debug_preview() {
   echo '<input type="hidden" name="debug_preview" value="debug_preview">';
}
add_action( 'edit_form_after_title', 'add_input_debug_preview' );

The preview worked since mid 2015 with this code. Recently with no code changes it stopped working. When we tried to track down the source and conflict, we realized it was caused by a conflict with a recent version of the Toolset Access plugin. An earlier version worked just fine.

Please let me know if you have other questions.

Miah

#559961

I must be missing something because I've added these hooks in functions.php and deactivated all plugins except ACFPro (I'm using their latest version, 5.6.1) and I'm not able to see the debug preview information in a post preview using this code in a PHP template (single.php):

 echo "Debug preview: " . get_field('debug_preview');

Any idea what I'm doing wrong? I'm able to see the hidden field in my editor, and when the preview pops up I'm able to see "Debug preview: " but nothing appears after it.

#560001

I can't be sure without seeing your implementation. ACF told me today that their latest version does not even need the hooks in the functions.php.

Let me run through the steps you need, just in case -

Create the Custom Field with ACF
1. Create a Custom Fields group from Admin > Custom Fields > Add New
2. Create a field named 'debug_preview' as field type Text, Textarea or WYSIWYG
3. Assign this field group to a post-type from the Location meta-box under the fields list area - i.e. to Page (Post Type is equal to Page)

WP Template
1. Edit the associated WP template for the post-type (i.e. page.php or single.php) and add the php code

echo "Debug preview: " . get_field('debug_preview');

Within the content loop so the global $post is set to the current post. If you place the above code outside of the content loop, use -

echo "Debug preview: " . get_field('debug_preview', $post->ID);

Where $post should be set to the current post.

Updating the Content & Preview
1. Now Edit a post-type matching your ACF fields assigned post-type (i.e. a Page)
2. Enter in some dummy content in the ACF field that appears on the Edit page.
3. Hit the preview button.

Please let me know if this is helpful for recreating the scenario.

Miah

#560064

Okay thanks, I'm able to reproduce the scenario and see the updated text now, but activating Access 2.4.2 has no impact on the preview text. I'm on WP 4.8.1, ACFP 5.6.1, Types 2.2.15.1, and Twenty Seventeen. The only plugins I have active are Types, Access, and ACFP.

Adding or removing the hooks from functions.php has no impact either - the edited preview always appears for me. Can you update to the latest versions of Types, Access, ACFP and WordPress, then retest? If this doesn't resolve the issue I'm going to need to make a clone of your site for further investigation. I will enable private reply fields here in case you want to provide admin credentials for me.

#560093

Okay thanks, I will enable private reply fields again.