What is wrong with this php loop?
- by Mark R
I made a loop but it doesn't work.
here's what I did:
<?php if(is_tree('4')) { ?>
<?php
$show_after_p = 2;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
$contents = explode("</p>", $content);
$p_count = 1;
foreach($contents as $content)
{
echo $content;
if($p_count == $show_after_p)
{
?>
YOUR AD CODE GOES HERE
< ?
}
echo "</p>";
$p_count++;
}
}
?>
<?php else : ?>
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
<?php endif; } ?>
I need to make it work but don't know how. I'm guessing it's a simple syntax error I'm not seeing?