Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#12870 closed defect (bug) (fixed)

Edit page for custom post type not showing slug & pretty permalink

Reported by: vlasky's profile vlasky Owned by: dd32's profile dd32
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

I am using 3.0-beta1. I have registered a custom post type called 'mycustom'.

In permalink settings, I have a custom structure of:
/archives/%postname%/

When I edit a post of my custom post type, instead of seeing the text box that displays the slug underneath the title, I see the following:

Permalink: http://wp.remoteexperiments.com:808/wordpress/?post_type=mycustom&p=44 and then a button marked 'Change Permalinks'

Enclosed is a screenshot, and here is the code I have used to register the custom type. Note that I have tried both with and without the 'rewrite' option.

$supports = array( 'title', 'editor', 'custom-fields', 'revisions');

$args = array ('label' => ('MyCustom'),

'singular_label' => ('MyCustom'),
'_builtin' => false,
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'supports' => $supports,
'exclude_from_search' => true,
'hierarchical' => false

'rewrite' => array('slug' => 'mycustom')
);

register_post_type('mycustom', $args);

Attachments (3)

MyCustomPostType.PNG (69.0 KB) - added by vlasky 15 years ago.
Screen shot of editor showing missing slug when editing a custom post type under WP 3.0-beta1
link-template.php.diff (566 bytes) - added by duck_ 15 years ago.
12870.diff (2.5 KB) - added by duck_ 15 years ago.

Download all attachments as: .zip

Change History (13)

@vlasky
15 years ago

Screen shot of editor showing missing slug when editing a custom post type under WP 3.0-beta1

#1 @uglyrobot
15 years ago

  • Cc aaron@… added
  • Resolution set to invalid
  • Status changed from new to closed

You have to enable rewrites for that post type, as well as configure them how you want. Custom post types will not be added to the default rewrite rules unless you add them manually.

#2 @vlasky
15 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

#3 @vlasky
15 years ago

  • Priority changed from normal to high
  • Severity changed from normal to major

Please read my report carefully - I included the option 'rewrite' when registering the custom post_type. I had tried both enabling and disabling that option.

After doing more research, I discovered that this issue was previously reported in ticket 12742 and patched in ticket 13865. Was this patch properly tested and rolled out in the last nightly build?

#4 follow-up: @vlasky
15 years ago

  • Priority changed from high to normal
  • Severity changed from major to normal

I changed this back to normal priority and severity so I don't seem overly self-important, but I just wanna say that it was wrong for uglyrobot to rush to declare this issue as 'invalid' without looking into it properly.

I also wish to note that another patch to address this problem was just released in 12895 by duck_

#5 @duck_
15 years ago

  • Keywords has-patch needs-testing added; slug permalinks removed

Managed to not read this properly when submitting #12895.

Anyway, problem is because you're editing a draft custom post type, only published custom post types show the pretty permalink. Patch attached.

#6 in reply to: ↑ 4 @uglyrobot
15 years ago

Replying to vlasky:

I changed this back to normal priority and severity so I don't seem overly self-important, but I just wanna say that it was wrong for uglyrobot to rush to declare this issue as 'invalid' without looking into it properly.

In your sample code you had rewrites commented out. That was expected behavior without defining a rewrite and query_var.

#7 follow-up: @dd32
15 years ago

  • Owner set to dd32
  • Status changed from reopened to accepted

See Also: #12742

Looks like i didn't catch it all..

I just noticed that the slug displayed may not be correct, for example, It showed /note/test/ in hte slug preview, and /note/test-6/ after a draft save when it realised test was already taken.

#8 @dd32
15 years ago

r14068 /trunk/wp-includes/link-template.php: Correct sample URL's for custom post_type's. uses pretty permalinks if possible. Props duck_. See #12870

#9 in reply to: ↑ 7 @duck_
15 years ago

  • Keywords needs-testing removed

Replying to dd32:

I just noticed that the slug displayed may not be correct, for example, It showed /note/test/ in hte slug preview, and /note/test-6/ after a draft save when it realised test was already taken.

Problem was that autosave.js was not sending a new_slug to admin-ajax.php, if this isn't set then it defaults to empty string. get_sample_permalink(_html) use null as a default for this value, so even though a unique slug was retrieved in the get_sample_permalink function it was overwritten because $name (aka the new_slug) was not null. Fix sets default for unset new_slug to be null. Also move the check for a new name in get_sample_permalink to before the unique slug call so that the same problem doesn't happen when editing the permalink of an existing post (try this now and you'll see that the number suffix isn't added until save).

PS, the patch also includes minor optimisation of _get_page_link function from link-template.php

@duck_
15 years ago

#10 @dd32
15 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [14124]) Display the correct Slug in the permalink preview. Props duck_. Fixes #12870

Note: See TracTickets for help on using tickets.