Can any bady help me please for you it is very easy..!

Discussion in 'PHP' started by strgraphics, Jul 24, 2009.

  1. #1
    i am using the wordpress site;

    in my home page it having like this


    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>


    then it will shows the all recent posts, but i want recent posts but from 2nd post only to display thats i want what i have to do..........,
     
    strgraphics, Jul 24, 2009 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $posts = array();
    while(have_posts()) {
    $posts[] = the_post();
    }
    print $posts[1];
     
    matthewrobertbell, Jul 25, 2009 IP
  3. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can try this if you are trying to view all posts from 2nd
    
    <?php if (have_posts()) : ?>
    
    <?php 
    $postId = 0;
    while (have_posts()){ 
         if( $postId != 0) {
               the_post(); 
         }
       $postId = $postId +1;
    }
    
    
    ?>
    
    Code (markup):

    I am not sure what the the_post(); function does though
     
    HivelocityDD, Jul 25, 2009 IP
  4. agilius

    agilius Well-Known Member

    Messages:
    1,021
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    100
    #4
    god why so complicated? :) $postId = $postId +1; no way!

    Simply do this:

    
    
    if(have_posts()) : have_posts(); while(have_posts()): the_post();
    endwhile;
    endiff;
    
    
    Code (markup):
    What will this do? Simply pass from the first post to the other :) have_posts goes from post number one too number two ;)

    If you liked it, say thanks and I'll give you a cookie :D

    It simply files variables like $post->ID with the right information. Function like the_content and the_excerpt require the_post function to run in order to know where to extract the info from.
     
    agilius, Jul 27, 2009 IP
  5. Chikey.ru

    Chikey.ru Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    matthewrobertbell, wrong code, u can see, that function the_post not return text, she display his.

    HivelocityDD, ou..

    agilius, i m too suprized at the complexity
     
    Chikey.ru, Jul 27, 2009 IP