Adding shortcode inside Visual Composer raw HTML [closed]
IT Nursery
May 23, 2022
0
I am using Visual Composer and have entered HTML into a Raw HTML element for a custom pricing table – I now would like to be able to use the World Currency plugin to show prices in different currencies.
The shortcode for World Currency is:
[worldcurrency curr="EUR" value="25"]
When I enter this into the Raw HTML it shows up as text exactly as above.
nothing shows and upon checking the source the whole echo is commented out in the HTML.
I also tried entering the HTML into a text block but things like tooltips no longer work properly and when entered as text rather than visual I lose the ability to edit the text totally.
Is there a way of using the shortcode within Raw HTML or another element within Visual Composer which will let me use the shortcode and HTML?
1 Answer 1
When you look at how do_shortcode() actually works, then it’s this:
do_shortcode( $content )
Where $content is defined as the following:
(string) Content to search for shortcodes
What you are trying to do is to echowhat the shortcode does, leading to a false assumption. There is no magic function discovering your shortcode. The shortcode simply is a callback (a function or a method) attached to some string that you can put between square brackets in full text content. When the content is read during the livecycle/runtime and is found, then the attached callback is executed in its place. Pretty much the same as what happens with actions and filters. So
What you are (or should be) searching for is where the shortcode gets added with add_shortcode(). Then just find the callback (for e.g. the bartag_func()) and execute or echo it