Function to Properly Render Cornerstone Content Outside of the Editor

Hi guys,

Hopefully an easy question for you. What function can I use to render Cornerstone content that’s not in the editor?

For many years, do_shortcode worked just fine. Now, it doesn’t work anymore. Instead, for some reason the content of the page just displays a second time.

So to specifically illustrate what I’m trying to do, here’s more info.

There’s a section in my footer (on some pages) where I display a portfolio. I’ve built this portfolio in Cornerstone, but I just copy the code into my template file.

In my wp-single.php template, I just have:

do_shortcode(’[cs_content][cs_section]… etc’);

And again, it worked flawlessly for many years. But now, instead of displaying the content, strangely it displays the content of the current post a second time. It’s very odd. I’ve tested it even with extremely basic Cornerstone content, and this still happens.

So I’m just wondering: is there a different function I should be using? Is there a reason this doesn’t work anymore? I get that it’s not the normal use case but I’m just wondering why something that worked without issue for so long is no behaving so strangely.

Thank you!

Hi @brianjohnsondesign,

Thank you for writing in, what do you mean do_shortcode() is not working? that is a core WordPress function, it should work.

Instead of having a bunch of shortcodes, please rebuild your portfolio as a Global Block, global block will give you a single shortcode, please use that with the do_shortcode() function.

Hope it helps,
Cheers!

Hi there,

I mean that instead of properly rendering the content, do_shortcode(), when used with Cornerstone content, will instead just duplicate the current post content, which is really odd. I suppose it’s possibly a core WP bug in the current version but I haven’t had issues elsewhere.

But a global block does make more sense. When I built this site, I don’t think that functionality existed yet so it wasn’t an option. I’ll give that a try.

Hi @brianjohnsondesign,

I also suggest you use the Global Blocks instead of the do_shortcode. Please let us know if you face any difficulties in using it. Please also read the following article on Global Blocks and how that can be used.


Thanks

Thank you!

That worked, and it was super easy. I already had a template block made of it, so I just created a global block added the template, and then updated the shortcode and it worked.

Very slick!

Actually, funny enough, in 2016 I wrote a blog article about how to make a reusable content block (basically a global block) in X Theme, long before the feature was actually implemented. Now that I think about it, I think one of your product developers called me about it once.

Here’s the post if you’re curious about it. Not sure it actually works anymore, nor would it be advisable!

Hi @brianjohnsondesign,

We’re glad that you’re able to figure it out! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.