Forums

[resolved] custom post type single post issue (4 posts)

  1. Jim Bouton
    Member
    Posted 6 months ago #

    I am editing a theme that uses a custom post type that works fine but when I try to view the single post it returns "page not found".

    I named the single "single-jj_projects.php" as the codex suggests but have had no joy.

    add_action( 'init', 'create_post_type_projects' );
        function create_post_type_projects() {
        register_post_type( 'jj_projects',
    	array(
    	'labels' => array(
    	'name' => __( 'Projects' ),
    	'singular_name' => __( 'Projects' )
    	),
    	'hierarchical' => true,
    	'public' => true,
    	'has_archive' => true,
    	'show_in_menu' => true,
    	'menu_position' => 5,
    	'supports' => array( 'title', 'thumbnail', 'editor', 'excerpt'),
    	'show_ui' => true,
    	)
        );
    }
  2. Rev. Voodoo
    Volunteer Moderator
    Posted 6 months ago #

    Have you flushed your rewrite rules? Either by code or manually?

    If not, go to your permalinks settings page and just hit save - then test

  3. Jim Bouton
    Member
    Posted 6 months ago #

    That worked perfectly, thanks for your help.

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 6 months ago #

    No problem, gotta flush the rules whenever you establish a post type or a taxonomy.

    It can be done in the code (I believe the CPT section of the codex has examples), but if you aren't creating these often, what you did above is only required when creating anything new - and that is often sufficient.

Reply

You must log in to post.

About this Topic