(Moderator’s Note: The original title was “viewing custom post types”)
I’ve setup a custom post type called 'recordings'
with a custom taxonomy called 'themes'
:
add_action('init', 'recordings');
function recordings() {
$args = array(
'label' => __('Recordings'),
'singular_label' => __('Recordings'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields')
);
register_post_type( 'recordings' , $args );
}
register_taxonomy("Themes", array("recordings"), array(
"hierarchical" => true,
"label" => "Themes",
"singular_label" => "Theme",
"rewrite" => true
));
I’ve read that I should now make a copy of page.php
, rename it recordings-page.php
and season to taste (code is as follows):
<?php
/*
Template Name: recordingsPage
*/
?>
<?php get_header(); ?>
<div id="container">
<div id="content" role="main">
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>
<?php $recent = new WP_Query('post_type=recording&posts_per_page=10&meta_key=Date&orderby=meta_value&order=ASC'); ?>
<?php while($recent->have_posts()) : $recent->the_post();?>
<?php the_title( '<h2 class="entry-title"><a href="' .
get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) .
'" rel="bookmark">', '</a></h2>'
); ?>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array(
'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ),
'after' => '</div>'
) ); ?>
<?php edit_post_link(
__( 'Edit', 'twentyten' ),
'<span class="edit-link">', '</span>'
); ?>
</div><!-- .entry-content -->
<?php comments_template( '', true ); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #container -->
But this is where I’m stuck. I’m not sure how I should call my recordings-page? I’ve added a new page called recordings, but all that shows up is the header/nav and the sidebar. I’m working with a fresh install using the TwenyTen theme. I’m sure I’m missing something here but I don’t know what.
I think it might be as simple as you needing to set the Page Template to “recordingsPage” as you can see in the following screenshots:
(source: mikeschinkel.com)
(source: mikeschinkel.com)
UPDATE
Looking again at your code it seems you define your post type as plural (
'recordings'
) andyet you refer to it as singular (
'recording'
) in yourWP_Query
. You need to be consistent; WordPress can’t figure out the difference (My experience says to go with singular all the way but if you have existing recordings in your database you’ll now need to update those records to use ‘recording’instead of 'recordings'
.)