0

On a website, I am using Wordpress shortcodes for French example words: [ex]beau[/ex] becomes <span class="ex" xml:lang="fr" lang="fr">beau</span>.

I would like to use the shortcode also in the title of a page/post. add_filter( 'the_title', 'do_shortcode' ); in the functions.php works almost perfectly, but the HTML title tag includes [ex]beau[/ex] now.

I am looking for a way to use a shortcode in the title of page/post (<?php the_title() ?> in my page.php), but it should not appear in the HTML title tag (<?php single_post_title(); ?> in my header.php).

Your help is greatly appreciated.

1 Answer 1

0

The PHP function strip_tags does the magic:

<title><?php echo strip_tags(get_the_title()); ?></title>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.