#13864 closed defect (bug) (worksforme)
'view' link on a custom post type wrong
Reported by: | mattsains | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description
I was testing custom post types with the following code in wp-content/themes/twentyten/functions.php:
function create_my_post_types() { register_post_type( 'super_duper', array( 'labels' => array( 'name' => __( 'Super Dupers' ), 'singular_name' => __( 'Super Duper' ) ), 'public' => true, ) ); }
When I created a new post type, clicking the 'view' link on this post goes to http://localhost/wordpress/blog/super_duper/new-super/ (which gives a 404), when it should go to http://localhost/wordpress/super_duper/new-super/ (which works, without the "blog/"). I have visited the permalink page to flush those. Refer to the screenshot to see where the link I'm taking about is.
Attachments (1)
Change History (6)
#1
@
14 years ago
Forgot to paste this line with the code (should start with this):
add_action( 'init', 'create_my_post_types' );
#2
@
14 years ago
- Component changed from Administration to Post Types
- Keywords multisite added
- Version set to 3.0
blog/ is needed for the main site.
Can you give us your permalink settings? I tried it with Custom Structure: /blog/%postname%/ and it works.
#3
@
14 years ago
Oh-
Although I did go to the Permalinks page to update them, I just tried that again and it now works as expected.
Sorry to waste a ticket ID...
(if you're still need it, my permalink settings are to "Day and name" in common settings)
#4
@
14 years ago
- Keywords multisite removed
- Milestone Unassigned deleted
- Resolution set to worksforme
- Status changed from new to closed
#5
@
14 years ago
Incase someone else finds this ticket (instead of opening a new one..)
When you create custom post types, You must flush the rewrite rules. You can either do this by $GLOBALSwp_rewrite?->flush_rules(); or by visiting the permalinks page and hitting save.
You should only ever flush the rewrite rules the first time your register the post type.
screenshot of the backend UI showing the bad link