One thing people ask me is “Rhys? How did you create the pages on Retro Garden such as the Arcade Game Reviews page on your site?”. The answer is simple, all you need to do is do some simple php & template editing. Today I’ll show you how:-

Copy page.php file & rename it to something else.

Very simple, go to your theme folder in your wp-content file & copy your page.php file. Rename it to the category you wish to target (such as 1.php or more useful web-tips.php for your “Web Tips” category).

Add The Following Lines to the page

Open the page within your web design software & add the following to the top of the file:-

<?php
/*
Template Name: Web Tips
*/
?>

Replace “Web Tips” with the name of your category.

Also, find the line that looks something like this:-

<?php while (have_posts()) : the_post(); ?>

And replace it with this:-


<?php query_posts('category_name=catname&showposts=-1&orderby=title&order=ASC'); ?>
<?php while (have_posts()) : the_post(); ?>

An explanation of the “query_posts” Line

Within the brackets of the query_posts(”) command, is where all the posts are retrieved. You may need to make a few changes. Here’s what each command (the bits between the “&”) do:-

  • category_name – The name of the category you want to show posts from. Change this to your category name you want to list on your page.
  • showposts – The amount of posts to show on the page. -1 means all posts will show.
  • orderby - How you want to order the posts, “date” is default, for this we will use the word “title”.
  • order – Can be one of two things. ASC (which means posts go from A to Z), and DESC (which means it goes from Z to A).

For this tutorial, you need to change the category_name to the name of the category. Other than that you can leave the rest.

Create a New Page With This Template

You then need to create a page with this template. To do this, click on “Page > Add New” in the sidebar, give the page a title, change the page template in the “Additional Attributes” box in the sidebar to the name of the template given in the previous step, and click “publish”. You now have a page which can be linked to from throughout the site.

Tags: , , , , | Comments: Comments Off

 
 

Comments are closed.

Subscribe to the comments on this post | Trackback URL

 
About Rhys

Rhys Wynne, the author of this blog, is a 20 something web designer from Colwyn Bay. Go to my favourite posts

Find out More

On Social Networks

Facebook Twitter Youtube Facebook Fan Page Linked In StumbleUpon Digg Delicious Myspace last.fm dopplr Problogger Blog Engage Problogger

Facebook
Twitter
Youtube
Facebook Fan Page
Digg
Delicious
Myspace
last.fm
Dopplr
StumbleUpon
Problogger.com Forums
Playfire
Blog Engage
Linked In

 

Sponsors