Error after deleting Inactive Block
-
After deleting an inactive block I can’t add a new block and get the message:
Notice: Undefined index: delete_mcb in wp-content\plugins\multiple-content-blocks\assets\inc\class-mcb.php on line 154I already have 6 blocks working fine on the page en they still do. But like I said, I can’t add a new one since deleting the inactive one. What can i do?
Thanks in advance!
-
The notice was probably there already.. what are you trying to do to create a new block Do you use some type of caching on the front-end?
Did you try disabling HTTP requests? (Settings > Multiple content blocks)
Thanks for your reply.
The notice appeared after deleting an inactive block. I have already 12 good working blocks on the same page. Now I can’t add a new block. It won’t appear when I add it to my template page while the first 12 blocks are still working fine.
I disabled HTTP requests when I started the project.
The steps I do to create a block is inserting <?php the_block(‘name’) ?> in my template page -> save -> refresh the frontpage.
I use MCB a lot with great succes but this never happened before
Hmm, I’ve never heard of this before. I don’t have time to try and reproduce this right now, but I’ll get back to you.
Ok, thanks for your time so far. π
Hi Dexels,
I’ve tried several things, but cannot reproduce this on a clean install. Added 4 blocks, removed one (also deleted it in “Inactive blocks”) and added a block. Everything worked fine.
Maybe there’s something else going on in your install. Could you try this on a clean WP install? If you still have this problem, could you give me more precise steps to reproduce?
Hi Harold,
I’m sure it works just fine on a clean install. I’ve worked with your plugin several times and it worked every time.
I think something went wrong when I deleted an inactive block while I activited the same block again in my template. So the block was not inactive anymore. I’m not 100% sure if that was the case but this could have happened.
Just tried this, but didn’t cause any problems. The block got cleared and re-added instantly. For now, I will assume this problem was caused because of a specific setup of some kind.
If you find our more, please let me know! π
Hey Harold, we deleted the database and added a new one. It works perfect now.
Bedankt voor je hulp en je fantastische plugin π
No problem, glad it worked out!
Hey Harold, It happened again but now I know what’s going wrong.
Between the blocks I have a section with posts. When I added my first post for that section, I saw all the blocks, which are positioned beneath the post section in my code, visable in the editor section of the post. When I posted the post, all content of the blocks below that section disappeared and I got the error Notice: Undefined index: delete_mcb in wp-content\plugins\multiple-content-blocks\assets\inc\class-mcb.php on line 154 again.
When I delete the code for showing the posts, the blocks are working again.
This is the code for my posts section.
<section class="block home-block home-block-referenties"> <div class="inner"> <div class="referenties-intro"> <?php the_block('referenties') ?> </div> <div class="swipe"></div> <ul class="referentie-lijst"> <?php query_posts('cat=1'); while (have_posts()) : the_post(); ?> <li> <div class="referentie-image"><?php the_post_thumbnail('thumbnail'); ?></div> <?php the_content(); ?> </li> <?php endwhile; ?> </ul> </div> </section>You probably don’t want to use
query_posts()anymore, especially for custom loops. This articles describe how to properly useWP_Query:
http://www.smashingmagazine.com/2013/01/14/using-wp_query-wordpress/
http://www.johnmorrisonline.com/how-to-create-a-custom-loop-in-wordpress-using-wp_query/And this describes how to use
pre_get_posts:
http://codex.ww.wp.xz.cn/Plugin_API/Action_Reference/pre_get_posts
http://devotepress.com/wordpress-coding/when-to-use-pre_get_posts-in-wordpress/#.VO76Y8ZqdoQYour problem will probably also be fixed by using
wp_reset_postdata()right after your query.What might be happening right now:
- You perform a loop of posts
- Each post is setup in $post
- You request a block outside of your normal loop
- The block of $post is initialized and requested. Wrong post!
- You have just added a block of content to the last post (or reference) that is shown.
Thanks, the wp_reset_postdata() works great. I’ve also used wp_query described by Smashing Magazine.
Thanks for your help.
The topic ‘Error after deleting Inactive Block’ is closed to new replies.