Support

Account

Home Forums General Issues Popups from custom posts are not passing ACF field data

Helping

Popups from custom posts are not passing ACF field data

  • I have an interesting quirk, here. I’m sure it’s something I’m doing wrong, but any advice would be much appreciated.

    What I’m trying to build is a one page with a grid of 10-15 company logos. I click a logo, and a modal popup box (custom post type in wordpress) appears that displays company data like company name, company url, company CEO, logo, etc. These are all ACF fields that I have created and associated to the edit screen on the custom post type from the modal popup plugin. I can create a new modal popup, and save all this data in the post using the ACF fields, just fine.

    Here’s where it gets weird. When i preview the modal popup in the wordpress admin editor, the data populates to the HTML output and pulls the correct field data using code like this – <?php $post_object = get_field('companyname'); ?>

    However, when i look at the modal popup launched from clicking a logo on the live page, all the data fields are empty.

    It’s as if, the get_field function is looking for these fields on the “page” rather than the custom post (modal popups) in which the data was recorded.

    How do I tell the modal template to look at the post data, and not the page data?

  • I’m not sure there is enough information. But, you’ll need to tell the modal template what post to get the values from and then use that in the acf function
    <?php $post_object = get_field('companyname', $post_id); ?> or at least that’s the way it sounds.

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

The topic ‘Popups from custom posts are not passing ACF field data’ is closed to new replies.