var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
How to show latest posts in the home page in wordpress website?
I set the front static page as 'page', which is the 'Home' page, and besides the main content in 'Home' page, I would like to add content of the latest posts also. So I made a sub page under 'Home' page, and set the 'posts page' in that sub page under 'Home' page. However, when I view the website, it just shows the main 'Home' page, with no any posts. Could you please tell me how to make the main content and latest posts both appearing in the front page? Thank you!
You can use the is_front_page() conditional :
the code between UL will show the Recent 5 Posts with Summary... if you would like to show only a List of Posts Title.. Replace all the Code between UL and /UL to :
<?php if( is_front_page() ) :?>
<?php $the_query = new WP_Query( 'showposts=5' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<li><?php the_excerpt(__('(more…)')); ?></li>
<?php get_archives('postbypost', '10', 'custom', '<li>', '</li>'); ?>
Thank you for the code. I added it in the 'Home' page, then I still couldn't see any post other than the main content, except one line of code:
have_posts()) : $the_query -> the_post(); ?>
Please tell me what is the reason? Thank you!
did you past this code before the Loop !?
You could also use the 'Widgets on Pages' plugin to add the 'Recent Posts' widget to your homepage.
UK/EU Shared Hosting UK & US VPS Hosting Charity (NFP) Hosting
Fast, Friendly and Reliable Hosting █
Litespeed Powered cPanel CloudLinux Softaculous Daily Offsite Backups █ 30 Day Money Back Guarantee - 99.9% uptime - 24/7 Dedicated UK support
Hi, thank you for the information. I just installed a plugin called 'Widgetize pages Light', and I wonder how to make a widget for it? Thank you.
Thanks for it
yes i try on this code and it work well
Originally Posted by
Oh, then maybe I didn't do it in correct way. Is it that I copy and paste the code into the 'Home' page through 'Text' platform, with 'code' brackets?
By varun0109 in forum Web Hosting
Last Post: 03-19-2012, 06:15 PM
By Lanny in forum Web Design and Content
Last Post: 10-09-2011, 10:06 AM
By jani in forum Web Design and Content
Last Post: 07-20-2010, 09:14 PM
By Jamie Harrop in forum Web Design and Content
Last Post: 02-04-2007, 12:13 PM
By abdoh2010 in forum Programming Discussion
Last Post: 04-23-2005, 06:47 PM