conditional shortcodes – WordPress Development Stack Exchange
I want to use a shortcode (
[ex]...[/ex]) within the title of a post in order to style the text in a certain way (
<h1>part of <span class="ex">title</span></h1>).
add_filter( 'the_title', 'do_shortcode' );, it works perfectly with
single_post_title which I use for
<title> contains the shortcode as plain text
<title>part of [ex]title[/ex]</title>. With
add_filter( 'single_post_title', 'do_shortcode' );, the title becomes
<title>part of <span class="ex">title</span></title>.
Is there a way to make shortcodes conditional: if it’s resolved within
the_title do this, within
single_post_title do that?
Leave an answer