Global Blocks for Cornerstone
Note: Global Blocks have now been integrated into Cornerstone and Pro Themes, so this plugin is no longer needed.
Have you ever wished you could create a section in Cornerstone and re-use it on multiple pages? How about doing that, and being able to edit them all in one shot? Well, wish no more. Introducing the Global Blocks for Cornerstone, brought you by Michael Bourne.
Oh, it’s also free for life.
This is a lightweight, easy to use plugin that allows you to create a “global block”, which is our way of saying a template that can be created in one location and reused anywhere. On top of that, once you edit the global block, everywhere it has been used will be updated as well.
How do I get it?
Your first step will be to download the Global Blocks for Cornerstone plugin directly off the WordPress repo.
Global Blocks for Cornerstone
Once installed, you will see a new entry in your wp-admin navigation called “Global Blocks”. This is a Custom Post Type created specifically for this plugin. It will be Cornerstone enabled by default.
Adding a Global Block.
Click Global Blocks > Add New. When adding a new block, you are free to use the default editor or Cornerstone. The default template when using X theme will be “Blank – No Container, No Header, No Footer”. This will give you a blank palette in which to create your block. Here you can make any layout imaginable in Cornerstone, with all available elements. What’s more is any custom CSS or JS you enter in Cornerstone will be printed (inline) with the Global Block where ever it is used.
Using the Global Block in a page.
After creating your block, open Cornerstone on the page you want to use ue it and simply drag the custom element where you want it. Select your chosen block from the drop down and it will appear! My advice here is to plan ahead for margins and padding. Most users will want to set the receiving section to 0 padding, and disable column container on the row. This way the Global Block will fill the entire section.
Custom Cornerstone Element
And that’s it! We are currently at version 1.0.0 and are open to any ideas for future advancements or new plugins. Roy and I are both accomplished WordPress developers, and we are eager to help the Themeco ecosystem with plugins such as this.
I tried Installing your plugin, but get this error every time.
Have both tried automatic search from plugin database and uploading manually, says the same thing every time.
Hey Vlad, thanks for pointing this out. A quick workaround to this error is to go to Plugins > Installed Plugins and activating from that screen.
However I believe I see what the problem was, the svn tag folder was saved inside the trunk folder by mistake. I just pushed a quick amendment to that and I installed it on two sites error free.
Worked like a champ for me! So easy and convenient vs the way I’ve seen others do similar things.
What if I wanted to insert these global blocks into posts, where I only use text not Cornerstone?
Never mind, I figured it out.
I just installed the latest update and GB has disappeared from the sidebar and the elements picker. XPro site, latest WordPress. Bill
Hey Bill,
Update to version 1.2.3 (it will be live soon), this will fix the issue.
Cheers
LOL – super real time support, just testing it now. The X templates approach is a mess, good idea but they should integrate your code.
Now working – I had to move my block to “Published” to make it appear on the dropdown for the GB element. Not sure it that’s normal but it’s working now.
By default, all posts should be saved as Published, yes. Glad you got it working.
FYI, moving a global block to trash does not remove it from view when using a short code. I haven’t tried with the cornerstone element to see if that makes any difference..
thanks for a great plugin 🙂
Thanks Craig! By default it shouldn’t as I grab the block by it’s ID, which remains intact even when in the trash. I haven’t come across a good argument to perform a check for the post being published or not. My thought is that if you are placing it on a page, you want it to show up there instead of the default “select a block” warning.
Hi Michael, Paul, I’ve discovered a bug you might or might not be aware of—There is a visual glitch in Pro edit-mode when using “The Grid” shortcodes in global blocks. Here’s the exact scenario: 1) Create global block with a Tab element 2) Add Grid shortcode (ex. [the_grid name=”abc”]) to one of the tabs 3) Publish global block 4) Add published global block to a page 5) BUG: The images contained within “The Grid” shortcode show up all over the page containing that global block with the abovementioned shortcode, when in edit mode. Note: They only show up in edit… Read more »
Hi brad,
While that is an extremely obscure and specific bug, I will definitely add it to the list to be looked at. Thanks!
Thanks Michael!
You can use CSS to target the Grid while editing, and hide it with display:none. While not perfect, it will avoid the mess when editing but not effect live views.
So basically Global blocks is a cool template that I can use say for like contact forms or newsletters signups and place anywhere on my pages? Very cool!
Yeah! So many uses for it, works great on multisite for adding blocks to all child sites as well. Glad you like it!
Hi Michael –
Can you tell me how / where to place a fb pixel on x-theme website (without child page) that will work across all pages of the site?
Many thanks,
Lauren
Your best bet is to use this plugin: https://en-ca.wordpress.org/plugins/duracelltomi-google-tag-manager/ And add the body tag manaully (with a child theme). The edit needs to be in the VIEWS/HEADER/BASE.PHP file.
Hi,
I created a global block and added in a page, but, it shows Comment form at the end of the page. I have turned off “Allow Comments” for the page in Cornerstone General Settings. It is not happening on any other page. Please help.
URL is: http://staging2.williamsrealtyutah.com/agents/
Thanks,
Main Pal
Hi Main, I’ve seen this before with plugins that were hooking in to the content filters to add dynamic sections. Due to that, I removed the content filter from my plugin last year, and simply grab the raw database text and do an echo do_shortcode. The Global Block CPT itself has no support for comments, so it wouldn’t be coming from there. My guess is a commenting system plugin, or another type of conflict.
Thanks Michael – I have found so many uses for this already!
One thing I am having trouble with. When I want to move a block to a different place in the Cornerstone editor it doesn’t allow me to grab it. It only highlights the text in the block. I have to delete it from its current location and place it again where I want it.
Any tips to resolve this?
Thanks!
Jay
I haven’t seen that myself, but like all Cornerstone glitches, the fix is often just to use skeleton mode 🙂
Easy enough. That worked – thanks for tip!
I am getting a 500 server error when using the plugin. I can’t decipher the exact error on the page but I can’t get a post to save when using the Global Blocks. Probably a plugin conflict. I love and need this really bad. Can you advise? This is the page I tried it on. https://processaccountant.com/kahn-method/
Hey Eric,
Any time you have a plugin conflict, it’s best to disable all your plugins and enable them one at a time until the error reappears. If you can do this, and let me know which plugin was at fault, I can take a closer look at what might be causing it.
This plugin piqued my interest when I first noticed it, yet having been bogged down with multiple projects, it became a “back burner” item.
I can’t tell you how FURIOUS I am at myself for not installing this sooner. Global blocks are an absolute godsend in terms of saving precious time! I’m still cringing at the hours I could have saved by checking this out sooner.
Thank you!
I’ve used Global Blocks on a few sites now and it’s truly a lifesaver. so thank you for this great addition to X-based sites. A site I’m currently working had something go funky and Global Blocks was removed and as such, I lost the two blocks I had setup, leaving shortcode in their place. I can rebuild the blocks relatively easily, but the shortcode lives on TONs of pages, so I was wondering if there was a way to change the block ID on the new blocks or if I have to roll the dice on a fond/replace and hope… Read more »
That’s a tough one. You would need to manually edit the database and edit the ID in the wp_posts table, and the corresponding post_id in the wp_postmeta table. Even then, no promise of it working (Cornerstone data is sensitive). Worth a shot though? Test it on a small block so you don’t lose too much time if it fails.
Jacob – Try the plugin Better Search & Replace. That will search through your entire database and can easily change those strings for you.
Phenomenal Plugins guys! Any plans on updating it with the new X Elements?
Thanks Aaron. It will still work with the Classic Elements. We will be updating it to work with V2 in the near future.
Hi Michael, do you know when Global Blocks will work with the new X Pro 1.2.7? I want to update a X Pro site but it is full with Global Blocks 😉
Technically, if you don’t add a new global block, it will still work. What WON’T work is adding any V2 elements (including sections.rows/columns) to a global block. You would have to duplicate an existing block and edit it to create a new one. Pro doesn’t give the option for creating a V1 section, so you have to copy them from old layouts.
Hello! Loved the video I found of this on the X Theme Resources YouTube Channel but I’m having some trouble implementing it. When I add the block via Cornerstone it shows up just fine, but when I view the page it simply says
{{yield}}
Where the content should be. Do you know what might be causing this?
That’s a new one for me Joseph, I’m afraid I don’t have any ideas other than the usual “disable your other plugins to see if there is a conflict”.
Hello, with the last update, I’m having big issues. Some time it work, and some time all I see is a bunch of code instead and I can’t install any global block. Any update planning soon ? I don’t want to find an other solution…
Global Blocks is not compatible with V2 elements. Technically, no plugin that inserts page or post data into another page will be compatible with V2 elements. I will be releasing a new version soon that allows for V2 sections, but you will have to stick with classic elements.
Any news on this plugin working with the latest version of Pro?
Any other solutions that work I could possibly use in the meantime?
Thanks,
Daniel
Hey Daniel,
This plugin will never be updated to work with V2 sections and elements. Currently the work around is to use V1 sections (sections built in Pro 1.1.1 and earlier) and Classic elements.
Themeco themselves may be working on an internal release of a global blocks type plugin for the new year, but there’s no timeline on that being given.
I’m very glad I found this. The site designer set up a section that appears on most pages – but it includes a picture that’s already out of date… My boss asked me to update it, and I realised I’ll have to manually delete the old block and add the new one on every page – but I intend to redesign that bit soon anyway.
When I do so, it’ll be a global block for sure!
Many thanks.
Thanks George!
Just a heads up, it’s best that you use Pro version 1.1.1 or earlier, or X Theme without the V2 elements upgrade. Global Blocks does not work on the new versions.
I am getting a {{yeild}} when I use this in a widget. Are we able to use it in them? Any help is appreciated.
Hey Jessica, you can add shortcode support to your site by adding the following line in your child theme’s functions.php file:
add_filter(‘widget_text’, ‘do_shortcode’);
Can you tell me how to put shortcode of golbal blocks in widgeted area? I am trying to put code in “Text” widget but it is not showing.
Hey Sansar,
You need to enable shortcodes in widgets. Drop this in your functions.php file:
add_filter(‘widget_text’, ‘do_shortcode’);