Skip to content

Make the Popup Maker CPT behave like a public post for ACF shortcodes to work inside popups #1086

@marklchaves

Description

@marklchaves

Describe the feature request

After ACF 6.3.4 they (WP Engine) added a "is_post_publicly_viewable" test in their logic. That test "fails" for popups, so the ACF shortcode won't run for popups by default now. When I added an ACF filter hook (see below) to ignore that check, my ACF shortcodes started working in popups.

/** Make the ACF fields available to non-public posts like popups. */
add_filter( 'acf/shortcode/prevent_access_to_fields_on_non_public_posts', '__return_false' );

Use case

When someone wants to use the ACF shortcode to display an ACF value inside the popup content.

Test case

Make sure your ACF settings are correct. I have some notes in this gist https://gist.github.com/marklchaves/75780b2d7ba9c9508e6da586147a859f.

  1. Create a popup.
  2. Create an ACF in the popup and give it a text value. E.g., "Hello, World!"
  3. Add the ACF shortcode to the popup's content editor. E.g., [acf field="test" post_id="1"].
  4. Test the popup. The popup displays without the value of the shortcode.
  5. Add the filter from the description section above.
  6. Retest the popup. Now, the popup should display with the ACF value.

Example screenshots (if any)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions