Validatating the_content with strpos
-
My brother wants to know if there is a way of having a small title for his posts every now and again, retaining the same original properties as the regular, large ones. I thought that probably the best way to do this would be to have a commented string somewhere in the posts, which, if found, would produce a small title.
I came up with a bit of code using strpos() to change the class of the h3 tag when necessary. The problem is that the code works fine if the required string is found, but if it is not found, the post is printed out as well as post-title.
This is the code I have:
<h3 class="<?php
$pos = strpos(the_content(), "<!--smalltitle-->");
if ($pos === false) {
echo "post-title";
} else {
echo "post-title2";
}
?>">
The topic ‘Validatating the_content with strpos’ is closed to new replies.