• Resolved greglfb

    (@greglfb)


    I’m finding the plugin doesn’t seem to like nested inserts.

    E.g., If I insert page C into page B, then insert page B into Page A, then Page A shows all of page B except the page C insertion. Can I get around this in settings, or is this a limitation of the plugin?

    Must add… I LOVE this plugin – it’s transformed my workflow, and I couldn’t do without it!
    Just upgraded to WP 4.7.3 and no problems so far.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Paul Ryan

    (@figureone)

    Howdy, right now it is possible with a hook that you can throw into your theme. By default, nested inserts are disabled to prevent someone accidentally inserted page A into page B and then inserting page B into page A (circular loop).

    In your theme, if you already have a function that hooks into init, just add this filter hook to disable the nesting check for the plugin:

    // Disable nesting check to allow inserted pages within inserted pages.
    add_filter( 'insert_pages_apply_nesting_check', '__return_false' );

    If you don’t have or can’t find an existing function that hooks into init, just put one into your theme’s functions.php file:

    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' );

    At some point I should just make this a configurable option on the Settings page for the plugin so you don’t have to add any code. Will let you know if that happens!

    Thread Starter greglfb

    (@greglfb)

    Thanks very much for this. I’ll give it a try!

    Thread Starter greglfb

    (@greglfb)

    I couldn’t get it to work, but this is almost certainly because I’m a complete WordPress noob and edited the wrong file or something!
    I’ve realised that I can get around my immediate problem by rethinking the way I’ve used the plugin in its unmodified form, which just goes to show how useful it is out of the box.
    Thanks very much for the advice.

    Thread Starter greglfb

    (@greglfb)

    Help! I’ve posted a question about an unrelated but urgent (as in site-killing) problem, but it’s been put in a 72-hour moderation queue for some reason.

    EDIT: Post is visible now. ??

    • This reply was modified 7 years, 8 months ago by greglfb.

    Hello!

    I used to use this solution in the past:

    ============ Add after:
    add_action( ‘after_setup_theme’, ‘spacious_setup’ );
    ============ these lines:

    // ****START******** for Insert Pages plugin
    function theme_init() {
    // Disable nesting check to allow inserted pages within inserted pages.
    add_filter( ‘insert_pages_apply_nesting_check’, function ( $should_apply ) { return false; } );
    }
    add_action( ‘init’, ‘theme_init’ );
    // ****END******** for Insert Pages plugin

    Now it makes an error with these lines, and without them the nesting would not work.

    I am using WP 4.4.8, Insert Page 3.1.8, Spacious theme 1.4.5.

    Please, help. How may this be resolved.

    Thanks a lot!

    Tamás

    p.s.
    I use Insert Page since a long time, and I just love it, and rely on it a lot.

    Hello, again!

    In the meantime I added what Paul suggested into the function.php
    as follows:

    // ****START******** for Insert Pages plugin
    function spacious_init() {
    // Disable nesting check to allow inserted pages within inserted pages.
    add_filter( ‘insert_pages_apply_nesting_check’, ‘__return_false’ );
    }
    add_action( ‘init’, ‘spacious_init’ );
    // ****END******** for Insert Pages plugin

    And with these lines it seems to work!

    Thanks, Paul!
    Great stuff! I love it.

    Greetings,

    Tamás

    Plugin Author Paul Ryan

    (@figureone)

    Glad you got it working! The problem with the other code was probably using an older PHP version that didn’t support anonymous functions (older than PHP 5.3, I think).
    https://php.net/manual/en/functions.anonymous.php

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Nested inserts possible?’ is closed to new replies.