Reputation: 59
I have a declaration of custom post type:
$labels = array(
'name' => _x('Partners', 'post type general name'),
'singular_name' => _x('Partner', 'post type singular name'),
'add_new' => _x('Add New', 'book'),
'add_new_item' => __('Add New Partner'),
'edit_item' => __('Edit Partner'),
'new_item' => __('New Partner'),
'all_items' => __('All Partner'),
'view_item' => __('View Partner'),
'search_items' => __('Search Partner'),
'not_found' => __('No Partner found'),
'not_found_in_trash' => __('No Partner found in the Trash'),
'parent_item_colon' => '',
'menu_name' => 'Partners'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our Partners and Partner specific data',
'public' => true,
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
'has_archive' => true,
'menu_icon' => 'dashicons-groups',
'public' => true,
'show_ui' => true, // UI in admin panel
'capability_type' => 'post',
'hierarchical' => true,
'rewrite' => array('slug' => 'partners'),
'has_archive' => true,
);
register_post_type('partners', $args)
; but when i query my custom post type it throws a Page not found error even if i already created my single-{custom-post-type}.php. When i enter the url of the post created it doesnt show the post, i also have a custom taxonomy for that custom post type
$labels = array(
'name' => _x('Partners Category', 'taxonomy general name'),
'singular_name' => _x('Partner Category', 'taxonomy singular name'),
'search_items' => __('Search Partner Categories'),
'all_items' => __('All Partner Categories'),
'parent_item' => __('Parent Partner Category'),
'parent_item_colon' => __('Parent Partner Category:'),
'edit_item' => __('Edit Partner Category'),
'update_item' => __('Update Partner Category'),
'add_new_item' => __('Add New Partner Category'),
'new_item_name' => __('New Partner Category'),
'menu_name' => __('Partners Categories'),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('hierarchical' => true, 'with_front' => false, 'slug' => 'partners')
);
register_taxonomy('partners_category', 'partners', $args);
can anybody shed some light?
Upvotes: 0
Views: 334
Reputation: 5221
I have find solution with testing:
register_post_type('partners', $args)
TO ';'
register_post_type('partners', $args);
Add after this value: "flush_rewrite_rules();"
register_post_type('partners', $args);
flush_rewrite_rules();
register_taxonomy('partners_category', 'partners', $args);
flush_rewrite_rules();
taxonomy-partners.php
archive-partners.php
single-partners.php
taxonomy-partners-tag.php
Upvotes: 0