Custom Post Types and Template Hierarchy
On the following dev site, I set up a custom post type for “Articles”. The post type name is “zu_articles” and the slug is “articles”. Everything is working in the Dashboard and I’m able to generate a listing of articles. But when you click the article link, it goes to a 404. I have the following page created: single-zu_articles.php based on my understanding of the WP template hierarchy.
There is a “Latest Article” widget under the content slider on the right to see everything.
Here is my code for creating the CPT
register_post_type( 'zu_articles', array( 'labels' => array( 'name' => __( 'Articles' ), 'singular_name' => __( 'Article' ), 'add_new' => __( 'Add New Article' ), 'add_new_item' => __( 'Add New Article' ), 'edit' => __( 'Edit' ), 'edit_item' => __( 'Edit Article' ), 'new_item' => __( 'New Article' ), 'view' => __( 'View Article' ), 'view_item' => __( 'View Article' ), 'search_items' => __( 'Search Article' ), 'not_found' => __( 'No Articles' ), 'not_found_in_trash' => __( 'No Articles in the Trash' ), ), 'public' => true, 'hierarchical' => false, 'exclude_from_search' => false, 'menu_position' => 20, 'query_var' => true, 'can_export' => true, 'has_archive' => true, 'description' => "Articles", 'rewrite' => array('slug' => 'articles'), 'supports' => array( 'title', 'editor' ) ) );
What am I doing wrong?
- The topic ‘Custom Post Types and Template Hierarchy’ is closed to new replies.