When you want to custom your wordpress site or you create wordpress template by yourself, you need to know how to display the recent information on the front page. You shouldn’t show all your articles on your homepage or maybe create a front page without any information of your recent post or your favorite post.
Yes, you have to maintain your articles properly in the front page due to make the visitor comfort to explore your site.
There are three options if you want to create recent post. Here they are:
- List format post with link (URL) only
This list format is the most common used in wordpress. You can add this code in your template code, for example on sidebar.php:
1<?php get_archives('postbypost', '10', 'custom', '<li>', '</li>'); ?>
- List recent post with link (URL) including preview post
The benefit of this method is that you can give a preview post after the link, so your visitor can read the preview content. If they want to read more, they can click the title and it will be redirected into a new page. This method is very helpful I think.
1234567<ul><?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 endwhile;?></ul>
- recent post covering full post.
This is not recomended by the way. But if you want to create it for purpose, it’s just okay. Although, we still can configure static page to make our favorite article stick on the front page.
|
1 2 3 4 5 6 7 |
<ul> <?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_content(__('(more…)')); ?></li> <?php endwhile;?> </ul> |
Recent Comments