Linking to list of blog posts with wordpress?
I've made my front page a static page with wordpress. I would still lik开发者_如何转开发e to be able to link to a listing of blog posts. How is this done?
create a new page template file called page-home.php best way to do this is copy and paste the code from index.php into your new page... inside this page create a new template call..
<?php
/**
Template Name: home
*/
?>
inside this page paste your index.php code..
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<?php the_content('<p>Read the rest of this page »</p>'); ?>
<?php wp_link_pages(array('before' => '<p>Pages: ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
<?php endwhile; endif; ?>
this will display your home page as usual, then you have to create a new call to the wordpress database to display your latest posts from which ever categories you want or show all posts from all categories..
<?php
//The Query
query_posts('posts_per_page=5&cat=YOUR_CATEGORY_HERE');
//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
..
endwhile; else:
..
endif;
//Reset Query
wp_reset_query();
?>
this will then loop through the posts and display your latest posts..
have a check through the wordpress query posts codex
精彩评论