I create a post and then it says i has been published but when I click the url I get a page not found!
Here is my custom post set up code:
add_action('init', 'offered_register');
function offered_register() {
$labels = array(
'name' => _x('Offered items'),
'singular_name' => _x('Item'),
'add_new' => _x('Give an item away'),
'add_new_item' => __('Give a new item away'),
'edit_item' => __('Edit item'),
'new_item' => __('Give Item Away'),
'view_item' => __('View Item'),
'search_items' => __('Search Offered Items'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/images/article16.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','thumbnail', 'custom-fields','comments')
);
register_post_type( 'offered' , $args );
}
Your
register_post_type()function looks fine. I’m guessing that you have pretty permalinks enabled. Visit the Settings > Permalinks page and try again.Then read this:
Flushing Rewrite Rules on Plugin Activation
The issue is that when a new post type is registered, the rewrite rules that WordPress uses to handle pretty permalinks do not automatically get re-generated.
flush_rewrite_rules()must be called to pick up the new post type rewrites. This is commonly done in two ways:flush_rewrite_rules()to the plugin activation hook callback (see the link above)flush_rewrite_rules()for youWhat you do not want to do is call
flush_rewrite_rules()in theinitcallback — it is not something you want called on every page request.