HEADER - Content Area Off Canvas - not parsing shortcode

Hey there,

I’m running into an issue since I last updated Pro - I had a shortcode in the Content Area Off Canvas that I used to display a a widget area. I created the shortcode in functions.php:

        dynamic_sidebar( 'ups-sidebar-fly-out-menu' );
    }
    add_shortcode('flyoutmenu', 'flyOutMenuShortcode');```

In the header I have this set up:

<img src="//tco-forum-uploads.s3.amazonaws.com/original/3X/2/0/20729bf858cd81e198cd92c93a70282082a6b85e.JPG" width="574" height="291">

Yet it doesn't show the widget area at all:

<img src="//tco-forum-uploads.s3.amazonaws.com/original/3X/2/b/2b53514b95ab73879306d17a412a405ce1bcf301.JPG" width="232" height="500">

There's a menu, search bar, another menu, and some social share buttons there. 

I'll attach a hidden post right after this with a URL where you can view the shortcode embedded into a page (to prove that the shortcode works) and will also have the menu where the shortcode is not parsing in the navbar. This worked before (I was a few releases out of date though)

Update - I’m actually seeing that it DOES parse the shortcode, but it’s adding it below the footer and not into the flyout.

Okay I figured it out, sorry guys. This was not your fault, but for those that are wondering, it was because dynamic_sidebar prints the sidebar to the page versus returning it. No idea why it worked with an older version of Pro, but here’s the fix:

function flyOutMenuShortcode() {
ob_start();
dynamic_sidebar( ‘ups-sidebar-fly-out-menu’ );
$sidebar = ob_get_contents();
ob_end_clean();

return $sidebar;
}
add_shortcode(‘flyoutmenu’, ‘flyOutMenuShortcode’);

1 Like

Hi Matt,

Thanks for the confirmation and the details!

Glad to know that!

Thanks

When looking at your 2 different codes… I see you have $sidebar… so with this function, you are basically able to set the output of flyoutmenu to $sidebar and then output it whenever you want?

Lastly, if you dont do ob_end_clean… can you use $sidebar later on and then clean after using it later?

Hi @kimmikennedy,

Yes, you can store any output to a variable and re-use it later even if you use ob_end_clean(). I think cleaning is about the data used in output buffer (OB) and it has no affect to the content already stored in a variable.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.