Support » Plugin: Insert Pages » Loading the wrong advanced custom fields

  • Resolved octavoscott


    I am using your plugin within a popup. I am using advanced custom fields and have selected the custom template option. BUT, the issue I am running into is that the template (using the_field or get_field) is pulling in the custom fields from the page
    that opened the popup, where I really need to load the custom fields from the page that is being inserted into the popup. Any ideas? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • After looking again, I need to somehow call the inserted page id not the actual page id. But don’t see how to do that.

    Plugin Author Paul Ryan


    You should be able to just include the_post(); at the beginning of your custom template to set up the global template variables that ACF relies on. Insert Pages should take care of resetting them to the container page after it finishes inserting the page.

    A little more explicit would be to include the standard loop wrapper in your custom template:

    <?php while ( have_posts() ) : the_post(); ?>
    <?php endwhile; ?>

    Finally, one other option would be to directly reference the (undocumented) inserted page WP_Post object within your template: $inserted_page
    So, for example, you could do: the_field( 'your-field-name', $inserted_page );



    Thanks, this was what I needed!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Loading the wrong advanced custom fields’ is closed to new replies.