• Resolved NeilMonteiro

    (@neilmonteiro)


    Hi,

    I’ve recently found that the MCB editors are no longer updating (or updating sporadically) as I change the page templates and I can’t figure out why!

    To be specific, if I add a new MCB block in a page template – or delete an existing one – the change isn’t reflected in the WordPress backend. Even more strangely, if I try changing the template associated with the page, the MCB blocks in the new template show up but blocks from the original template NEVER disappear.

    I’m not using any caching plugins on the site, and it’s not a browser cache issue as I can load the page fresh on a different browser and the problem persists.

    Any ideas appreciated!

    Neil

    https://wordpress.org/plugins/multiple-content-blocks/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter NeilMonteiro

    (@neilmonteiro)

    I should mention too that I’ve tried switching off HTTP requests and it hasn’t helped…

    Thread Starter NeilMonteiro

    (@neilmonteiro)

    I think I’m narrowing this down. New blocks added to the beginning of the template page show up fine in the editor. Blocks added towards the end don’t turn up at all.

    Clearly there’s something wrong going on in the middle of the page… Does it matter that I’m using get_posts() in the middle of the page?

    For reference, template is here:

    http://pastebin.com/LTdrCP8m

    Calls to “TestBlock” and “TestBlock3” in lines 17 and 18 work fine, “TestBlock2” at line 170 doesn’t.

    Thread Starter NeilMonteiro

    (@neilmonteiro)

    For anybody else with the same problem, I seem to have solved this myself:

    The problem seemed to be that I was using get_posts() in my template so the global $post variable was set to something other than the page I was working in. I assume that the_block() uses $post to attach each block to the correct page.

    To solve this, I called the wordpress function wp_reset_postdata(); after I was done with the get_posts() loop – i.e. before I next called the_block().

    Hope this helps someone!

    Plugin Author Harold Angenent

    (@harold-angenent)

    Neil,

    Thanks for clarifying. You’re right – the_block uses $post. But there are a lot of widgets and plugins that use $post (maybe even some of your own), so I would advice to always reset postdata after a new loop (get_posts is probably not a problem, but WP_Query is).

    Regards,
    Harold

    Thread Starter NeilMonteiro

    (@neilmonteiro)

    Thanks Harold, I really should have read the codex page on the Loop at some point (http://codex.wordpress.org/The_Loop) where this is mentioned!

    Thanks for the fantastic plugin – it provides essential functionality for me!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘MCB not updating in editor – cache issue?’ is closed to new replies.