Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#13864 closed defect (bug) (worksforme)

'view' link on a custom post type wrong

Reported by: mattsains's profile 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)

screenshot-backend.JPG (70.4 KB) - added by mattsains 14 years ago.
screenshot of the backend UI showing the bad link

Download all attachments as: .zip

Change History (6)

@mattsains
14 years ago

screenshot of the backend UI showing the bad link

#1 @mattsains
14 years ago

Forgot to paste this line with the code (should start with this):

add_action( 'init', 'create_my_post_types' );

#2 @ocean90
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 @mattsains
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 @ocean90
14 years ago

  • Keywords multisite removed
  • Milestone Unassigned deleted
  • Resolution set to worksforme
  • Status changed from new to closed

#5 @dd32
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.

Note: See TracTickets for help on using tickets.