Title: Loading the wrong advanced custom fields
Last modified: July 14, 2019

---

# Loading the wrong advanced custom fields

 *  Resolved [octavoscott](https://wordpress.org/support/users/octavoscott/)
 * (@octavoscott)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/loading-the-wrong-advanced-custom-fields/)
 * 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)

 *  Thread Starter [octavoscott](https://wordpress.org/support/users/octavoscott/)
 * (@octavoscott)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/loading-the-wrong-advanced-custom-fields/#post-11730996)
 * 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](https://wordpress.org/support/users/figureone/)
 * (@figureone)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/loading-the-wrong-advanced-custom-fields/#post-11749793)
 * 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 );`
 *  Thread Starter [octavoscott](https://wordpress.org/support/users/octavoscott/)
 * (@octavoscott)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/loading-the-wrong-advanced-custom-fields/#post-11764365)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/insert-pages.svg)
 * [Insert Pages](https://wordpress.org/plugins/insert-pages/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-pages/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-pages/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-pages/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-pages/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-pages/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [octavoscott](https://wordpress.org/support/users/octavoscott/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/loading-the-wrong-advanced-custom-fields/#post-11764365)
 * Status: resolved