WordPress.org

Make WordPress Core

Opened 14 months ago

Last modified 10 months ago

#44270 new defect (bug)

Non-public custom post types have rewrite rules enabled by default

Reported by: TheDeadMedic Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

Is there a reason for the pairing of public => false with rewrite => true for default custom post type arguments? If there isn't can we change the default rewrite to inherit public at runtime?

I often see a large rewrite rules array from plugin/theme private post types not declaring rewrite => false - if there's no need for them seems bit of a waste - a default WP install is 17 rules per post type, 17 possible unnecessary regex checks per-request. Usually it's two or three CPTs I see per site and they stack up quick.

Attachments (1)

44270.1.patch (1.9 KB) - added by ryanshoover 10 months ago.
Changes rewrite parameter to the default of publicly_queryable

Download all attachments as: .zip

Change History (2)

@ryanshoover
10 months ago

Changes rewrite parameter to the default of publicly_queryable

#1 @ryanshoover
10 months ago

  • Keywords has-patch added

Just submitted a patch that would take care of this need. Changes the default of rewrite to be the value of publicly_queryable (which takes the default of public).

publicly_queryable made the most sense since rewrites determine the pretty URL for a post if you query it on the frontend.

Note: See TracTickets for help on using tickets.