Opened 13 years ago
Closed 9 years ago
#20571 closed defect (bug) (worksforme)
problems with slug and view in custom post types
Reported by: | thomask | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 3.3.1 |
Component: | Posts, Post Types | Keywords: | has-patch close |
Focuses: | Cc: |
Description
when creating custom post type, there are 2 minor problems
- when setting rewrite to false, it is not possible to edit slug (edit button missing) - this is wrong as slug is needed e.g. for get_post queries by name
- if the post is set not publicly_queryable, then anyway the post edit screen shows "View [custom post name]" and "Preview" button, which then points to 404 screen.
Attachments (1)
Change History (9)
#3
@
11 years ago
I can confirm issue 1 reported by @thomask. To clarify his steps:
1) Register a new post type (I used the books example from http://codex.wordpress.org/Function_Reference/register_post_type)
2) Create a new book ("Jurrassic Pak") and save, the permalink will be: http://localhost/?book=jurrassic-pak
3) Whoops! You realize there's a typo in your title, so you correct it to "Jurassic Park" -- but the typo is still in the slug, there's no way to update the posts's slug!
However on Issue 2 (publicly queryable), this IS documented in the codex as a gotcha ("Note: If you set this to FALSE, you will find that you cannot preview/see your custom post (return 404).") and seems to be a hotly debated topic in other tickets: (#17609) and (#20098).
I'm going to attempt issue #1, I'd recommend pursuing issue #2 as a separate ticket or via one of the related ones (#17609) and (#20098).
#4
@
11 years ago
The attached diff fixes the issue reported by @thomask; I've tested and verified my diff in the following scenarios:
- When the cpt has rewrite = true
- When the cpt has rewrite = false
- When the cpt has capability_type = post
- When the cpt has capability_type = page
I'm unable to see any diff when using postname vs. pagename as the replacement var; I went with postname b/c it seemed more universal
#7
@
9 years ago
- Keywords close added
My 2 cents:
Issue 1:
Actually I disagree here. Even when rewrite is false, you are able to change the slug. If you go to Screen Options, you can tick the "Slug" box, which will allow you to edit the slug. The slug box was suggested to be removed in that case (see #18523), but as I stated there, I oppose to that, as anyone might need to edit the slug even for non-publicly-queryable posts.
Issue 2:
This is tracked separately in this ticket: #17609
So, it appears there is nothing else to be done here - I mark this ticket for closure.
Related: #20098