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.

(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.

share|improve this question
    
it doesn't look like my code for recordings-page.php showed up entirely. am I not formatting it correctly? –  don de lion Feb 22 '11 at 7:08
    
here's my recordings-page.php code:; –  don de lion Feb 22 '11 at 7:16
    
@don de lion - I reformatted for you. All likes of code must be indented 4 spaces to format correctly. –  MikeSchinkel Feb 22 '11 at 7:18
    
oh thank you - I just found that info too. –  don de lion Feb 22 '11 at 7:19
    
@don de lion: What do you want to do? Create an "archive page" for multiple recordings, using a "fake" page? Or a template for a single recording? –  Jan Fabry Feb 22 '11 at 8:26
show 3 more comments

1 Answer

up vote 2 down vote accepted

Hi @don de lion:

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:

UPDATE

Looking again at your code it seems you define your post type as plural ('recordings') and yet you refer to it as singular ('recording') in your WP_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'.)

share|improve this answer
    
Hi Mike, I did set the page template to recordingspage as well, but it didnt' change. I think I'm just not really calling the posts I've made? I guess I expect my custom post to be seen as a regular post, and I'm confused when I don't see it in the Recent posts section of the sidebar, for example. Apologies if this is too sophomoric; I get a little fuzzy when digging through the code (but working on improving that). –  don de lion Feb 23 '11 at 6:39
    
@don de lion - See my update. –  MikeSchinkel Feb 23 '11 at 13:03
    
okay I've made the change to recording on the post type, but it's still the same. .. I found a tutorial - justintadlock.com/archives/2010/02/02/… - and added the following code: add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if ( is_home() && false == $query->query_vars['suppress_filters'] ) $query->set( 'post_type', array( 'post', 'recordings'' ) ); return $query; } –  don de lion Feb 24 '11 at 5:47
    
heres the code: add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if ( is_home() && false == $query->query_vars['suppress_filters'] ) $query->set( 'post_type', array( 'post', 'recordings', ) ); return $query; } –  don de lion Feb 24 '11 at 5:55
    
now all posts show up on home page: regular and custom. this is the right direction I'm thinking? The site's for showcasing a series of archival recordings on numerous topics, w/shared tags across many of the individual talks. Preferably, there'd be a page called, for example, seminars, w/excerpt posts in the main content area, along w/a 'browse categories' section in the sidebar & a custom search bar for searching by word/topic. I'll be reading the tut(s) mentioned above, but am I thinking this through proper? any and all comments greatly appreciated. –  don de lion Feb 24 '11 at 6:02
show 1 more 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.