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
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
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.
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(); ?>
<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: http://thedaneshproject.com. 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.