Jul
26
Create a page link to the blog posts in Wordpress
Filed Under Wordpress |
We have designed a sophisticated Wordpress CMS for one of our clients. The site is www.quantumconsulting.org. In this site, we created a static home page and a page link to the blog post. The blog link has a pretty permalink http://www.quantumconsulting.org/blog. Besides that, we also incorporated a newsletter contact form on the front page.
You may be interested in how we create a page link to the blog posts with such a nice permalink. Here is our step-by-step method:
- Create a new file called blog.php and copy the content of the index.php to the blog.php
- Make the blog.php a page template by pasting the following code on the top:
<?php
/*
Template Name: Blog
*/
?> - Create a new WordPress “page” (Write > Page) and name the title “Blog”
- Scroll down to the “Advanced Options” and expand the “Page Template” section. Choose “Blog” from the drop down menu. Click Publish
- Edit the blog.php file.
Find
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Replace with
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts=5'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
Find
<?php else : ?>and remove it and any thing that has to do with it.
Find
< ?php endif; ?>
Replace with
<?php $wp_query = null; $wp_query = $temp;?>
That is all. I got the solution from this post.
Comments
4 Responses to “Create a page link to the blog posts in Wordpress”
Leave a Reply



Alfred,
Thanks for sharing! Thanks to you and Nathan, i can better implement this now. I spent several hours customising a static front page but could hardly work out how to get the posts under a single page. The newsletter contact fom looks great, how this that done; i am using cforms but i am too much of a ‘dummy’ (about 4 months old WP user) to get it to the front that cool way.
Bless u,
BSK
I’m new to PHP and recently setup my local machine with PHP and MySQL for doing development. I was sort of stuck when I needed to post my work for the user to test and review. After looking around a bit I found a site that hosts PHP and MySQL apps. I was surprised that it was free - it seems they’re offering the service at no cost until 2012. At that point they’ll change over to a fee-based service. However, in the meantime, it’s a great place to do anything from demo and sandbox right up to posting sites for real.
Their pitch is as follows:
“This is absolutely free, there is no catch. You get 350 MB of disk space and 100 GB bandwidth. They also have cPanel control panel which is amazing and easy to use website builder. Moreover, there is no any kind of advertising on your pages.”
Check it out using this link:
http://www.000webhost.com/83188.html
Important: There’s one catch in that you must make sure you visit the account every 14 days - otherwise the account is marked ‘Inactive’ and the files are deleted!!!
Thanks and good luck!
Wow thank you for the step by step tutorial, very helpful!
I love using the blog page template. I have been using a dynamic homepage with lots of teaser information and a static blog page on most of my blogs for quite some time. It is a good way to put out a lot of information in a small space.
The second great thing about having a blog page is you can make it less graphically intense than your homepage or post pages making it a good spot to attract the attention of those using slower connections.
The best reason to have one though I found out recently is to have a backup portal into your blog. My host had problems with their upgrade which messed up my install and subsequently my homepage. Through wordpress I was able to simply redirect incoming traffic to the blog page. This give me time to not only fix the problems a new install caused but to mull over redesign ideas I wanted to make on the homepage.