Problems using strip_tags with the title
One of the problems arising while adding html code to the title is that such code goes also into the “title” atribute of the link the title points at.
I have this:
Imagine I write as title White Elephant
the output would be:
When such a thing happens the XHTML validation engine tells me the following:
character “<” is the first character of a delimiter but occurred as data.
A way I thought I could overcome this problem was by applying the strip_tags function to the_title() function but nothing happened:
” rel=”bookmark” title=”Permanent Link to <?php strip_tags(the_title()); ?>”>
<?php the_title(); ?>
Then searching for info I found out about filters and that at wp-include/default-filters.php a filter called wptexturize (defined at wp-include/functions-formatting.php).
So I went to wp-include/default-filters.php where I found the line saying
Just in case I decide to comment it. I assume that maybe this filter turns into < and > and, thus, strip_tags does not see it. But this does not make much sense anyway since the title that gets shown shows bolded text and not the entities of the signs.
So now I do not know what to do to make sure the_title gets its’ tags removed when shown in the “title” attribute and not when shown normally.
Has anybody solved this problem before, I have found information about it but no solutions are explained as far as I have searched.
- The topic ‘Problems using strip_tags with the title’ is closed to new replies.