With WordPress is becoming one of the largest self-hosted blogging tool across the globe, its benefits are being exploited by millions of site owners and is being explored by tens of millions of people each day. Everything that has been created on WordPress has been crafted by and for the community. Since it is an open source it gives you an opportunity to modify it to the suit your needs. One of them is displaying your recent posts to generate traffic and benefits beyond discussion in this article. Here are some ways for you to display recent posts and keep your readers informed on all your recent updates.
(Image Source: WordPress.org)
1. It’s easier than you might think
Of course you don’t require any training or custom queries for this one. All you need to know is the inbuilt function in WordPress to get the recent posts on your static web page. And that’s not all – you can create your own widget with no plugin. Being more than a blogging system, you can try the below mentioned coding and go miles amongst your readers.
This could be a great start for you as a beginner and later also try giving links to your recent posts. You can also use the function wp_get_archives() with which some parameters can help you publish recent WordPress posts.
2. Some technical friendly idea
To give this idea a try, you should have the WordPress installed on a PHP Web Server else you should use a web hosting. To get started you would need a code editor along with FTP support. You should also be familiar with XHTML and a little CSS and PHP. Open your code editor and the file where you would want to add this snippet. Try for top of the page and at the area where you would like your recent posts to appear type the following:
$args = array( ‘numberposts’ => 6,
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
Opting to explore this idea can help you experience the world of WordPress. Infact you can use some tricks even to hide or mask posts as per your convenience and choice. You can even customize your default Recent Posts widget to show or hide your posts by categories.
Displaying Recent Posts in a List Format
The list format is mostly used in sidebars of WordPress pages. You can display the recent posts by simply pasting the following code in a template file of your choosing for example sidebar.php:
<?php get_archives(‘postbypost’, ’10′, ‘custom’, ‘<li>’, ‘</li>’); ?>
You can change the number 10 to the number of posts you like to display.If your theme support Widgets, then there is an easier option for you. You can simply head over to the widgets page and add Recent Posts widget to your sidebar. That will save you from editing the codes.
Displaying Recent Posts with Full Content
Some people like to display recent posts with full content if WordPress is being used as a Content Management System (CMS).
<?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>
This is mostly used to make a page look like your blog page.So you should not need this if you are not running a CMS.
All you need is a little time and you can easily display your recent posts as a WordPress user. Since this tool has a wonderful CMS capability you can actually design your page and site as per your style and mind. It can get really easy to add this option to your sidebar and get famous amongst your target audience. Always remember the code editor may highlight some errors but the PHP code will take care of all your worries in this case. It will execute the code with the help of .htaccess snippet. Try to create a fresh page to test this functionality before you try this on your live page.
Written by Alyssa. Edited by Aritra Roy.
Alyssa has been doing internet marketing, SEO Services for last 5 years. She loves travelling, meeting new people and works at SEO Morpheus.