Wordpress page-template: page with posts in a category
With wp-page_category template you can customize your Wordpress adding a page template with a typical page followed by the index of posts in a specific category (look at an example).
- Open the page-template Page with category and save it from your browser (File > Save page as…).
- Rename the file
wp-page_category.txtinwp-page_category.php. - Open the template Navigate posts and save it from your browser (File > Save page as…).
- Rename the file
navigate_posts.txtinnavigate_posts.php. - Using an free software ftp client (like Filezilla) copy both the files
wp-page_category.phpandnavigate_posts.phpinto yourwp-content/themes/<your theme folder>/. - Login at your website and write a new page.
- Select the Page with category template as page-template.
- Create a custom field with
displayed_categoriesas Key and the numeric id of the category you want to display as Value. - Publish the page.
- Visit the page you have just published.
License
©2008 by Lorenzo De Tomasi. Copyleft/Some rights reserved. The php code has been released under a Gnu/Gpl 3.0 license.
Future improvements
- Make the
<!--more-->work. [Can you help to understand the problem? Thanks] - Set the number of post listed for each page, using pagination buttons. If no value is set, display the default number of posts.
- Display more than one category at time (for example books and dvds), using comma separated numeric category-ids (131, 12, 36).
- Check if
displayed_categoriesis set. - Check if categories exist.
Tags: free software, page template, php, WordPress






Leave a Reply