Simulate shortcodes with javascript

Question

I found out that [shortcode] are not showed in the post excerpts, so I was thinking about a workaround with javascript: keep the notation [shortcode], deleting its definition, and finally add a javascript which replace it with the html code of the original shortcode definition.

Say we have the following shortcode

add_shortcode( 'VF', 'vf_sc' );
function vf_sc( $atts ){
    return "<span class=boxed><b><font color=00CD00>V</font>|<font color=red>F</font></b></span>";
}

with boxed defined as

.boxed {
    padding: 0 5px;
    border: black 0.7px solid;
}

is it possibile to write a javascript which replaces the string [VF] with <span class=boxed><b><font color=00CD00>V</font>|<font color=red>F</font></b></span> ?

So that even by deleting the definition of the shortcode, I can still write [VF] in the editor and keep the same output.


EDIT

Each post on my site starts with

<p class=textbox><b>,,,</b> ...</p>

where ,,, is the topic, and ... a short description. Sometimes the description contains also the shortcode [VF].

This textbox is shown in the excerpt of each post when searching for them using the search bar.

0
, sound wave 4 years 2019-11-05T08:40:56-05:00 0 Answers 73 views 0

Leave an answer

Browse
Browse