• I’ve set my homepage as a static WP page that I created..

    I have wrote my welcoming stuff but now I want to under that display 5 or 6 posts excerpts. I’ve tried the get posts php code but that doesnt work..

    Any help please?

    thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You want a second WP loop beneath your main post code.

    It will be something like this (exact depends on your theme):

    in your page.php template file:

    find the end of your present loop:

    </div>
    <?php endwhile; endif; ?>
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>

    beneath that add:

    <?php $myPosts = new WP_Query("showposts=6");
       while($recent->have_posts()) : $recent->the_post();?>
    	<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    	<?php the_excerpt();?>
     <?php endwhile; ?>

    after that will be the rest of the original code, something like this (don’t change any of the original code at all):

    </div>
    <?php get_sidebar(); ?>

    oops, use this code instead:

    <?php $myPosts = new WP_Query("showposts=6");
       while($myPosts->have_posts()) : $myPosts->the_post();?>
    	<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    	<?php the_excerpt();?>
     <?php endwhile; ?>
    Thread Starter markey101101

    (@markey101101)

    does that make it on only one page or every new page that I create?

    stvwlf

    (@stvwlf)

    You can make it only on one page by creating a custom page template and assigning that template to your front page

    For starters copy the content of your page.php file to the new template file, and add the code above to the new file.

    http://codex.wordpress.org/Pages#Page_Templates

    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘A way to dsiplay 5 or 6 posts excerpts on front page..’ is closed to new replies.