• can someone direct me on how to do this, im using wordpress; Im using get_posts to retrieve the newest post and display the 2 previous post in a <li> tag on my index page

    like below:

    This a new post!
     -old post 1
     -old post 2

    the desire i want is very simple, when a new post is being created, user’s dont have to reload the browser to update the index page.

    Here’s my get_posts as above.

    //DISPLAYS THE NEWEST POST
    <?php
    global $post;
    $args = array( 'numberposts' => 1, 'category' => 1 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    	<div class="post"><h1><?php the_content(); ?></h1></div>
    
    <?php endforeach; ?>	
    
    //SHOWS 2 PREVIOUS POST
    <?php
    global $post;
    $args = array( 'numberposts' => 2, 'offset'=> 1, 'category' => 1 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    	<li><?php echo get_excerpt(40); ?> - <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

  • The topic ‘update a in index page without reloading’ is closed to new replies.