I’ve created a custom post type, and have successfully added a few entries. I can call these entries out with query_posts()
to show on the front page, but the_permalink()
on each of them just sends me to a “Page not found” 404.
Am I missing something? I’m currently running on http://localhost
, so the results of the_permalink()
from the front page custom post type loop sends the user to http://localhost/PU/PU2010/website/cartoons/einstein-on-california
.
functions.php
function createCartoonPostType() {
register_post_type( 'cartoon', array(
'label' => 'Cartoon',
'public' => true,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments' ),
'rewrite' => array( 'slug' => 'cartoons' )
) );
}
add_action( 'init', 'createCartoonPostType' );
According to this, I should be able to just create single-cartoon.php
, correct?
single-cartoon.php
<?php get_header(); ?>
<div class="container_20">
<div class="grid_14">
<div class="bodybox">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
</div>
</div>
<div class="grid_6">
<?php get_template_part( 'social', 'box' ); ?>
<?php get_sidebar(); ?>
</div>
<div class="clear"></div>
</div>
<?php get_footer(); ?>
loops-cartoons.php (frontpage loop)
<?php query_posts( 'post_type=cartoon&posts_per_page=1' ); ?>
<div class="cartoons-box">
<ul class="cartoons-list">
<?php if ( ! have_posts() ) : ?>
Sorry, no posts.
<?php else : while ( have_posts() ) : the_post(); ?>
<li>
<a href="https://wordpress.stackexchange.com/questions/3954/<?php the_permalink(); ?>" class="preview-image">
<?php the_post_thumbnail( 'featured' ); ?>
</a>
</li>
<?php endwhile; endif; ?>
<div class="clear"></div>
</ul>
</div>
<?php wp_reset_query(); ?>