• Hi there. I’d like to either show the content, or not, based on whether a certain string is found in the content itself. This is what i have, but it’s not working:

    <?php
    	$thecontent = basename(the_content(10));
    	if(strpos($thecontent, '[flickr') > 0): ?>
    		<p>Show text 1</p>
            <?php else :?>
    		<p>Show text 2</p>
    <?php endif;?>

    First off, the content gets shown on the page because of the variable assignment. Then the conditional doesn’t seem to work. Any suggestions?

Viewing 1 replies (of 1 total)
  • I don’t know what the purpose of the ’10’ was in your sample, but the way to get the content is to get_the_content(). ??

    <?php
    	$thecontent = get_the_content('Read more ...'));
    	if(strpos($thecontent, '[flickr') > 0): ?>
    		<p>Show text 1</p>
            <?php else :?>
    		<p>Show text 2</p>
    <?php endif;?>
Viewing 1 replies (of 1 total)
  • The topic ‘search the content for a string, and a conditional’ is closed to new replies.