Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

We're creating a site to showcase a series of archival recordings covering a wide variety of topics. We'd like to have a page in the main navigation (e.g. recordings) to display these by title, w/a browse by category option, and have heard the best way to do this is w/custom post types. We're able to start this setup by editing the functions.php page, as well as using the 'custom post UI' plugin, but do not understand how to actually show the custom posts, either in a list style on the recordings page, or otherwise. What is the next step? Any and all help is appreciated.

don

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

In the template for your recordings page you'll want to specify a custom query for the post type in question.

$rec_query = new WP_Query('post_type=recording');

And then later in your template, you will refer to the query object you created directly instead of relying on the default. For example:

while ($rec_query->have_posts()) : $rec_query->the_post();
share|improve this answer
    
Oh now I understand--we have to query the new post type.. will try this and let you know our progress. Thank you for your response. -Don –  don de lion Mar 2 '11 at 5:41
add comment

If you are using the latest version of WordPress 3.1 the its very easy,

copy your themes single.php file in to a new file named single-recording.php and just before the line:

if(have_posts()...

add

query_posts('post_type=recording');

and if you want to create archive "like" display of you post type (similar to category listing but just for your post type) then copy your theme's archive.php file in to a new file named archive-recording.php and again before the :

if(have_posts()...

add:

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
      'paged' => $paged,
      'post_type' => 'recording'
);

query_posts($args);

and to make sure the pagination works find the line that looks like this:

endwhile; else:
 ..
endif;

//and Reset Query by adding:
wp_reset_query();
share|improve this answer
    
These responses are very helpful; am piecing these answers together now - will let you know how we progress. thanks so much. –  don de lion Mar 2 '11 at 5:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.