Simulate shortcodes with javascript
-
Each post on my site starts with
<p class=textbox><b>TOPIC</b> description</p>where
TOPICis the main argument of the post (usually 1 or 2 words), anddescriptionis a brief sentence explaining more about the content. This textbox is shown in the excerpt of each post when searching for them using the search bar.In some cases the description contains
<span class=boxed><b><font color=00CD00>V</font>|<font color=red>F</font></b></span>, which I later replaced with the shortcode[VF].But now I found out that shortcodes are now shown in the post excerpts, so I was thinking about a workaround with javascript: keep the notation
[VF], delete its shortcode definition, and finally add a javascript which replaces it with the html code of the original shortcode definition.This is how the shortcode
[VF]is actually definedfunction vf_sc( $atts ){ return "<span class=boxed><b><font color=00CD00>V</font>|<font color=red>F</font></b></span>"; } add_shortcode( 'VF', 'vf_sc' );where the
boxedclass id 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 obtain the same output?
The topic ‘Simulate shortcodes with javascript’ is closed to new replies.