• Resolved ger01

    (@ger01)


    I have a WordPress static home page, what I want to do is to display the last two posts from the blog page at the bottom of the homepage below other content.

    I have searched and looked at plugins, and used yd-recent-posts widget which does exactly what I want but this means that you have to put code into the content which can be easy deleted by mistake.

    What is the best way of doing this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Could put a simple loop in your Page Template. The Pages article has some examples. Essentially it is something like:

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 2,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
        the_content();
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Thank you I will take a look at it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pulling posts to different pages’ is closed to new replies.