WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#26277 closed defect (bug) (invalid)

Codex entry on "register post type" has incorrect information

Reported by: beowulfenator Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Permalinks Keywords:
Focuses: Cc:

Description

The Codex entry on the "register_post_type" function contains inaccurate information about the "rewrite" argument.
In the entry, the fields are named 'feeds' and 'pages', whereas the correct parameters to the function "add_permastruct" that gets called eventually are 'feed' and 'paged'.

Change History (10)

#1 @Hanni
4 years ago

Are you talking about the rewrite section on this Codex entry http://codex.wordpress.org/Function_Reference/register_post_type? If so, you can edit the page (as with any Codex page) at its edit link which, for this page, can be found here.

#2 @Hanni
4 years ago

  • Keywords needs-codex removed
  • Resolution set to invalid
  • Status changed from new to closed

#3 @Hanni
4 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

#4 @beowulfenator
4 years ago

Oh, I didn't know it was user-editable. Fixed it. Thanks!

#5 @beowulfenator
4 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

#6 @SergeyBiryukov
4 years ago

  • Keywords needs-codex added

That article documents the parameters for register_post_type(), not for add_permastruct().

For register_post_type(), the parameters were correct.

As documented in the inline docs, it's feeds and pages there, not feed and paged:
tags/3.7.1/src/wp-includes/post.php#L1275

In line 1316, feeds is mapped to feed (see [24830] for #23302):
tags/3.7.1/src/wp-includes/post.php#L1315

Not sure why pages is not mapped, but it appears to be handled above. Probably worth investigating further.

I've reverted the Codex change since it's incorrect.

Last edited 4 years ago by SergeyBiryukov (previous) (diff)

#7 @SergeyBiryukov
4 years ago

  • Keywords needs-codex removed

#8 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted

#9 @beowulfenator
4 years ago

Oops. I was looking at 3.6.1, and there is no such mapping there. But I see it is fixed now. Thanks!

#10 @beowulfenator
4 years ago

I tested this with 3.7.1, and here's what I got:
If register_post_type for a custom post type named "deposits" with 'pages'=>false, the following two rules are created (among others):

individuals/deposits/([^/]+)/page/?([0-9]{1,})/?$
=>
index.php?deposit=$matches[1]&paged=$matches[2]

individuals/deposits/([^/]+)(/[0-9]+)?/?$
=>
index.php?deposit=$matches[1]&page=$matches[2]

However, if I call it with 'paged'=>false, the first rule is not created.

I believe this is incorrect.

Last edited 4 years ago by beowulfenator (previous) (diff)
Note: See TracTickets for help on using tickets.