Title: shortcode inside a page with another shortcode infinite load
Last modified: February 22, 2019

---

# shortcode inside a page with another shortcode infinite load

 *  Resolved [masterbip](https://wordpress.org/support/users/masterbip/)
 * (@masterbip)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/)
 * Hi there. A weird issue.
    Scenario: I am using this to disable “nesting check”
 *     ```
       function your_theme_init() {
           // Disable nesting check to allow inserted pages within inserted pages.
           add_filter( 'insert_pages_apply_nesting_check', '__return_false' );
       }
       add_action( 'init', 'your_theme_init' );
       ```
   
 * Now:
    I got 4 pages with normal content plain short demo test text: 1.- Index
   2.- Page-2 3.- Page-3 4.- Page-3-Child
 * In INDEX I [Insert Page-2] and [Insert Page-3]
 * Browse Index: All is fine till here.
 * If in Page-3 I [Insert Page-3-Child]
    Browse Index: I got the infinite loop and
   the page load down infinity….
 * Using a simple template:
 *     ```
       <?php
       /*
       Template Name: Demo_Template
       */
       while ( have_posts() ) : the_post();
       ?>
       <section>
       	<div class="insert-page-wrap">
       		<div class="insert-page-content">
       		<?php the_content(); ?>
       		</div>
       	</div>
       </section>
       <?php endwhile; ?>
       ```
   
 * Logically I am not nesting anything
    I got like A -B -C –D
 * Is this a normal behavior if I disable nesting check?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Paul Ryan](https://wordpress.org/support/users/figureone/)
 * (@figureone)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/#post-11237088)
 * Thanks for the detailed steps to reproduce. That scenario should work, we’ll 
   look into it!
 *  Plugin Author [Paul Ryan](https://wordpress.org/support/users/figureone/)
 * (@figureone)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/#post-11237179)
 * Ok, tracked down the issue. Using Custom Templates in Insert Pages relies on 
   the old `query_posts()` WordPress function, which has some drawbacks. If you 
   look at the docs, it will try to save the global `$wp_query` variable into a 
   backup global variable, `$wp_the_query`. However, This immediately gets overwritten
   when you insert your nested page, so WordPress is unable to restore the original
   query.
    [https://developer.wordpress.org/reference/functions/query_posts/](https://developer.wordpress.org/reference/functions/query_posts/)
   [https://developer.wordpress.org/reference/functions/wp_reset_query/](https://developer.wordpress.org/reference/functions/wp_reset_query/)
   [https://developer.wordpress.org/reference/functions/wp_reset_postdata/](https://developer.wordpress.org/reference/functions/wp_reset_postdata/)
 * I’ve updated Insert Pages to cache it’s own version of `$wp_query` that we restore,
   which allows for nested pages all using Custom Templates.
    [https://github.com/uhm-coe/insert-pages/commit/cc002fc0f2cf80ef01285404ed5c5342011cb22c](https://github.com/uhm-coe/insert-pages/commit/cc002fc0f2cf80ef01285404ed5c5342011cb22c)
 * This fix is included in version 3.4.5, just released. Thanks for the report!
 *  Thread Starter [masterbip](https://wordpress.org/support/users/masterbip/)
 * (@masterbip)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/#post-11237278)
 * Updating now Ill let you know.
    By the way. Where can I “buy you” a “coffee cup”?
   Paypal … something?
 * THANKS A LOT
 *  Thread Starter [masterbip](https://wordpress.org/support/users/masterbip/)
 * (@masterbip)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/#post-11237302)
 * YOU ARE MY BEST FRIEND NOW!
    Working perfect, THANKS! It is absolutely pure magic
   what we can do with your plugin!
 * For real, let me buy you a Coffee Cup
 * Thanks, AWESOME!!!!
 * (When finished I’ll give you my project URL so you can show as portfolio -> It
   will be LEGENDARY!)
 *  Plugin Author [pkarjala](https://wordpress.org/support/users/pkarjala/)
 * (@pkarjala)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/#post-11237831)
 * [@masterbip](https://wordpress.org/support/users/masterbip/) Thank you for the
   feedback! We fortunately get paid to work on and support this plugin through 
   our regular job. If you would like to add to this support, please consider a 
   donation at [https://coe.hawaii.edu/alumni-giving](https://coe.hawaii.edu/alumni-giving)
 *  [funsail](https://wordpress.org/support/users/funsail/)
 * (@funsail)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/#post-11332580)
 * Hi, with the new update, we still need to use this?
    add_filter( ‘insert_pages_apply_nesting_check’,‘
   __return_false’ );
 * You could say I’m scared of doing this and making a loop
 *  Plugin Author [Paul Ryan](https://wordpress.org/support/users/figureone/)
 * (@figureone)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/#post-11332779)
 * You’ll need to add that code if you want the nesting level to go deeper than 
   1 (e.g., A inserted in B, B inserted in C, so when you view C, you see B including
   A’s content inside it). If you make a loop, you’ll probably get the [WSOD](https://codex.wordpress.org/Common_WordPress_Errors#The_White_Screen_of_Death)
   when trying to load the page. Simply remove (or comment out) the code for `insert_pages_apply_nesting_check`,
   and it will go back to only allowing one level of nesting, which will prevent
   the loop.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘shortcode inside a page with another shortcode infinite load’ 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/)

## Tags

 * [infinite load](https://wordpress.org/support/topic-tag/infinite-load/)
 * [insert Page](https://wordpress.org/support/topic-tag/insert-page/)
 * [nesting](https://wordpress.org/support/topic-tag/nesting/)
 * [problem](https://wordpress.org/support/topic-tag/problem/)

 * 7 replies
 * 4 participants
 * Last reply from: [Paul Ryan](https://wordpress.org/support/users/figureone/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/shortcode-inside-a-page-with-another-shortcode-infinite-load/#post-11332779)
 * Status: resolved