Shortcode in topbar

I want to show the latest post in header Topbar so I downloaded the Latest Post Shortcode plugin.

But it seems I cannot get the shortcode to work in header, it only prints out the actual code, not the result.
This is the code I enter into the Topbar content box:
[latest-selected-content limit=“4” type=“post” display=“title,content-small” chrlimit=“50” image=“full” elements=“0”]

How do I do this?

(I found several year old posts where a child theme was suggested but I hope this is not needed in 2020…)

Hi Max,

The topbar area is a small space that is why it does not accommodate shortcode contents. Please install and activate the child theme and login through FTP then edit the functions.php then add this code:

add_filter('x_option_x_topbar_content', 'top_bar_content_shortcode');

function top_bar_content_shortcode ( $content ) {
    return do_shortcode ( $content );
}

Hope this helps.

Thanks. I was hoping I would not need a child theme. In an old forum post (2014?) it was stated that you would support shortcode in topbar in a future version, so I was hoping for that. I don’t really see why you would not do that, it should be such an easy thing to add?

Hello Max,

Please understand that the Topbar content only accepts a plain text. You will need a child theme to modify the default setting of the topbar content so that if you put a shortcode, it can be rendered in the topbar content.

Hope this makes sense.

Yes I understand, but is it still a feature request to allow shortcode in topbar, that you plan to implement in a future version?

Hey Max,

We certainly appreciate the feedback! This is something we can add to our list of feature requests. This way it can be taken into consideration for future development. All of these items are discussed with our team internally and prioritized based on the amount of interest a particular feature might receive.

Thanks!

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