adsense

How to Display Custom Post Types in Wordpress 3.0





1. Open up the index.php file -- or the template file in your theme containing the main WordPress posts loop -- in the text or code editor of your chosing.
2. Find the line of code where your loop starts, which starts with
. Change 'your-custom-post-type' to the ID of your custom post type. The 'posts' type in this example is the regular, default post type used by all WordPress blogs.

3. Find the end of your loop's code -- the
and
tags -- and add the follow line of code below them:
. This code ends the query so that it will not interfere with other loops.
4. Create a theme template file called 'single-your-post-type.php' where 'your-post-type' is replaced by the name of your custom post type. This file acts like single.php, so the easiest way to create it is to copy and paste the single.php file and save it with the correct filename. There are no other steps to creating this template, because WordPress will look at its filename when deciding how to handle its contents. This template file will show a single post in your custom post type.
5. Create a theme template file called 'archive-your-post-type.php' where 'your-post-type' is replaced by the name of your custom post type. This file acts as the archives page for all posts in that custom post type. To create the necessary code for this template, copy and paste your theme's archive.php code.

Comments

0 Responses to "How to Display Custom Post Types in Wordpress 3.0"

Post a Comment

Popular Posts

About