• Resolved ajcke

    (@ajcke)


    I’ve created a custom post type plugin (following a tutorial). When I add a new post and then view the post I get a 404 error. Below is the code in the plugin.

    add_action( 'init', 'create_movie_review' );
    function create_movie_review() {
        register_post_type( 'movie_reviews',
            array(
                'labels' => array(
                    'name' => 'Movie Reviews',
                    'singular_name' => 'Movie Review',
                    'add_new' => 'Add New',
                    'add_new_item' => 'Add New Movie Review',
                    'edit' => 'Edit',
                    'edit_item' => 'Edit Movie Review',
                    'new_item' => 'New Movie Review',
                    'view' => 'View',
                    'view_item' => 'View Movie Review',
                    'search_items' => 'Search Movie Reviews',
                    'not_found' => 'No Movie Reviews found',
                    'not_found_in_trash' => 'No Movie Reviews found in Trash',
                    'parent' => 'Parent Movie Review'
                ),
    
                'public' => true,
                'menu_position' => 15,
                'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),
                'taxonomies' => array( '' ),
                'menu_icon' => plugins_url( 'my-photo-sessions/camera.png', __FILE__ ),
                'has_archive' => true
            )
        );
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • catacaustic

    (@catacaustic)

    I’ve found that a lot of times you need to reset your permalinks when you add a new custom post type because it doesn’t update WordPress’s internal routing without doing that. Just go to ‘Settings -> Permalinks’ and change to ‘Default’ then back to what you have set now and try again and it should work.

    Thread Starter ajcke

    (@ajcke)

    Thanks! That did the trick.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type Plugin 404 Error’ is closed to new replies.