I have created a custom posttype labeled 'Richards' using a site-specific plugin with the following code.
function add_richards_posttype() {
$labels = array(
'name' => _x( 'Richards', 'Post Type General Name' ),
'singular_name' => _x( 'Richard', 'Post Type Singular Name' ),
'menu_name' => __( 'Richard\'s Dagboek' ),
'parent_item_colon' => __( 'Parent Richard' ),
'all_items' => __( 'Alle Richards' ),
'view_item' => __( 'Bekijk Richards' ),
'add_new_item' => __( 'Nieuwe Richard' ),
'add_new' => __( 'Nieuwe Richard' ),
'edit_item' => __( 'Bewerk Richard' ),
'update_item' => __( 'Update Richard' ),
'search_items' => __( 'Zoek Richard' ),
'not_found' => __( 'Niet Gevonden' ),
'not_found_in_trash' => __( 'Niet Gevonden in Trash' ),
);
$args = array(
'label' => __( 'richards' ),
'description' => __( 'Richard\'s Dagboek' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'revisions' ),
// 'taxonomies' => array( 'kickstarters' ),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
);
register_post_type( 'richards', $args );
}
add_action( 'init', 'add_richards_posttype', 0 );
I have added data using richards
as a posttype, which shows up with the correct posttype in the database. When I want to display either the archive page or single page for this custom post type (by visiting site.com/richards/
or site.com/richard/
), WordPress serves a 404 error page.
The reason I have public set to false is to block not-logged-in users from accessing this posttype. Logged-in users should be able to access site.com/richards/ while not-logged-in users should not.
I have searched for the solution for quite a while now and I have tried adjusting permalink settings and changing these back, adding and removing an archive-richards.php file (although I want the styling to fall back on regular posts styling), adding and removing a menu button with ?post_type=richards
behind it and some other methods I can't recall.
What else can I try? How would I go about finding the solution now?
"public" => TRUE,
public
andpublicly_queryable
in the Codex forregister_post_type
. I think there's an important distinction to be made there.