The single-project file is only for displaying singular entries, so if you want something that lists all the projects you’ll need to create a page do that…
Generally the easiest route to doing that is using a page template attached to a page that fetches posts with the custom post type..
NOTE/TIP: Don’t name the page “Project”, give it a plural, so “Projects” … else the rewrite rules for your page and custom post type entries (the singular ones) will conflict with one another.
Hi Mark
Thanks for replying – I’m actually trying to create a single page.
I’ve created a page with all the projects, no problem at all. When I click through, though, I just get a ‘page not found’ error, despite having single-project.php in my themes folder.
Here’s my code, if that helps.
//Register projects
add_action('init', 'project_register');
function project_register() {
$args = array(
'label' => __('Projects'),
'singular_label' => __('Project'),
'public' => true,
'show_ui' => true,
'publicly_queryable' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title', 'editor','excerpt')
);
register_post_type('project', $args );
}
What’s the URL you see when you get page not found?
It should be example.com/project/your-project-name (additionally including the directory if WP is installed in a directory)..
If you have permalinks setup in a way that adds additional data to the front of permalinks you’ll need to set with_front to false when you registering the post type…
See the rewrite parameter on this page in regard to with_front.
http://codex.wordpress.org/Function_Reference/register_post_type
NOTE: If you need to make that change to the post type registration code then you’ll also need to save your permalink settings afterwards in order for the rules to get regenerated (simply visit the permalink settings page and hit save).
Hi Mark
Thanks for your reply.
Yes, that’s exactly what should’ve happened. I revisited the permalinks the page was creating within the post area, and they seemed correct. So I tried to ‘preview’ the page, and sure enough it worked.
I then went back to my original page and tried the clickthrough to the page that should call this template. And this time it worked.
I have no idea what’s happened here. All I know is that it certainly didn’t work, and now it does. Which is perhaps just as frustrating, as I can’t imagine that previewing a page would have any affect whatsoever.
Oh well, all’s well that works properly.
Thanks again
Chris
Strange, but glad to hear it’s all working for you now.. 😉
I’ve been reading more about custom post types over the last few days.
I’ve read elsewhere that simply visiting the permalinks page can fix this problem. So perhaps that’s what I did.