• Hi there, I would like to style the first paragraph of my post. That is to say make the opening paragraph look different than the rest of the content. I’ve tried this in CSS:

    .entry-content p:first-child {
    	color: red;
    }

    But only blockquotes receive the new code and appears red. The first paragraph is untouched. What would be great, though, is a PHP code that separates the first paragraph and gives it a different class.

    Is there anyway of doing this? Something like:

    ?php
    $show_after_p = 1;
    $content = apply_filters('the_content', $post->post_content);
    if(substr_count($content, '<p>') > $show_after_p)
    {
    	$contents = explode("</p>", $content);
    	$p_count = 0;
    	foreach($contents as $content)
    	{
    		echo $content;
    
    		if($p_count == $show_after_p)
    		{
    		?> ...

    … I don’t know! I just can’t hack it and I’ve been searching forums everywhere for three days now. Please help, much appreciated. You can have a look at My New Website to see the bloody blockquote is only affected.

  • The topic ‘Style the First Paragraph of My Post’ is closed to new replies.