How to create a wordpress Page that takes post from the main page.

I always wondered as I have seen wordpress themes that has more than one page section. I have tried to create one page but I get a static page. What’s the use of a static page other than for ABOUT??!? A static page is a page that you can use or post ONE thing only. So I tried to find how can I populate this Page using categories from my main page posts……………..I couldn’t find any. I tried using my limited knowledge in wordpress as a newbie, I couldn’t find anything. At last one of my friend, Danny (check out his site) helped me out to get another of his friend’s code from his wordpress that has the similar setup.

So here is what you need to know:

1. First of all create a page. Lets call it techie. You might want all your techie posts in your blog to get to this page. So you can categorize more than topic and create pages like this if you like later. So for now we stick to a page called techie
Photo Sharing and Video Hosting at Photobucket

2. Next you will to create a page template. This in wordpress are all PHP files. So I will need to create a copy of it and call it tech stuff. First of all using a FTP client like Filezilla, copy out your default page template like this
Photo Sharing and Video Hosting at Photobucket

Usually it will be in this path: /public_html/wp-content/themes/*yourtheme*/. The file usually will be called something like page.php. So once you have a copy on your local deskstop. Rename the file and upload it again. So now you have one copy of page.php which is called as tech stuff.php for example.

3. Once you have this done. Go back to Manage>Pages>techie, change the page template to point to the newly created tech stuff.php template. Good!
Photo Sharing and Video Hosting at Photobucket

4 . Next is the most important stuff. Go to Presentation>Theme editor> Tech stuff.php or any other name that you have used to name your techie page template. Type in this in the first line on the page:

Template Name: Tech stuff

Done? Good! Make sure that this file can be updated by you. How do I make sure its append able? Using your FTP client, go to the file and make sure you have enable read and write permission (in *nix speak its 666… weird number to represent if you know what I mean… 🙂 ). The update button will appear automatically on your wordpress theme editor once you refresh. Once you update it, type in this:

<?php rewind_posts(); ?>
<?php query_posts(‘cat=52&paged=’.$paged); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>

Beware where you write this few lines. You will need to write this few lines just AFTER

<?php get_header(); ?>
<div id=”content”>


<h2><?php the_title(); ?></h2>

lines. You will need to get the line positions correct if not you will be having problems. Now, you will notice I have this cat=52 highlighted, why? Here is where you define what category will you post on your new page…. now, like I said before, since its a Tech page with techie stuff, my category ID is 52. Now how do you know what is your category ID? Easy peasy, just get to this page : Manage>Categories. Here you will see all categories that you have on your page. Just get the ID which you want to post on the new page and replace the category ID on the code line.

What if you need more than one category to be shown, simple, just add the category ID after a comma, eg: cat=52,110,101,10101,1010101,101010 etc.
Pretty straight forward right?

5. Now, what you need to do is do a double check. Post a test page and categorize it as the one that you want it to show on the new page. Do you see it? Cool! There you go.

Let me know if you guys have any problem, I will see if I can help. Danny my man, thanks for your help man.. Appreciate it ! 🙂 Check out his site: My next step is to make the home page devoid of the tech category that I have choosen. That means, whenever I post about a tech category, it goes straight to the tech page rather than having two copies of the post; one on the main page another on the tech page… Stay tuned.


~ by bassplayr on November 26, 2007.

4 Responses to “How to create a wordpress Page that takes post from the main page.”

  1. Thanks so much for this post! I looked all over the place to find out how to filter a single category to a page. Great explanation and it works great! One thing, I’d say to people, beware when you copy and paste the code through the text area when editing your your template. I noticed when I did so, it pasted unrecognized single and double quote characters causing the template not to work. Once I figured that out and changed them, it worked like a charm. Thanks again!

  2. Thanks man. Hope you are working a bit on your blog. I am a bit low now because of all the festive season….. 😦 Should peak again. Happy reading.

  3. Parse error: syntax error, unexpected ‘=’ in /home/content/c/a/r/carlpitts/html/wordpress/wp-content/themes/lightbreaker/chadpage.php on line 9
    Is there error I get

    there is no

    it says post-entry instead of content. I tried changing to content to no luck. Any help??

  4. Hi. This little template “hack” I was looking for a ten hours and it was so simple. Thansk, this was verry useful for me.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: