I am creating a news website using wordpress, i want to create a front page that should display latest 2 post from each category , how can i create that?
I am creating a news website using wordpress, i want to create a front page that should display latest 2 post from each category , how can i create that?
<?php
$categories = get_categories();
foreach($categories as $cat):
query_posts("cat=".$cat->term_id."&showposts=2");
while(have_posts()): the_post();
echo "<h2><a href='".the_permalink()."' rel='Bookmark of {the_title()}'>". the_title()."</a></h2>";
echo '<p class="'.post_class().'">'.the_content("Read more...").'</p>';
endwhile;
endforeach;
?>
Write this code in your front page file.
i set a static page as front page , can i write this code in html tag
first include the wp_blog_header.php file in your front page file. file should be .php file not .html file.
if i use a wordpress page as home page , whre i have to write above code then where i have to save ? or can i create an external file for this?
i want to publish 2 latest post from each category in front page. i am new to wordpress and php , please guide me
Put this code in the page template file you are using for your static front page.
This topic has been closed to new replies.