Show first and second paragraph on the homepage

Discussion in 'WordPress' started by khurramalvi, Nov 18, 2010.

  1. #1
    How can I show first and second paragraph on the homepage and in between I want to show a post image? Similar example can be seen on smashing magazine homepage http://www.smashingmagazine.com/

    Here is the code I have done, which shows first paragraph of the post and image. After image it shows whole content instead of second paragraph only.

    <?php
        $paragraphAfter= 1; //shows image after paragraph 1
        $content = apply_filters('the_content', get_the_content());
        $content = explode("</p>", $content);
        for ($i = 0; $i <count($content); $i++) {
        if ($i == $paragraphAfter) { ?>
        <?php images('1', '', '', '', true); ?>
        <?php
        }
        echo $content[$i] . "</p>";
        } ?> 
    PHP:
     
    khurramalvi, Nov 18, 2010 IP
  2. daljit

    daljit Well-Known Member

    Messages:
    312
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #2
    you can simply insert the image in Post after the first paragraph in editor in wordpress admin section.I think this will help you?
     
    daljit, Nov 18, 2010 IP
  3. khurramalvi

    khurramalvi Well-Known Member

    Messages:
    111
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #3
    I believe you haven't understand request properly. Good news is I got a solution from another forum. Follow link below to find answer:

    http://www.webhostingtalk.com/showthread.php?p=7125307
     
    khurramalvi, Nov 18, 2010 IP