Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#36685 closed defect (bug) (worksforme)

Cannot edit the default args of default post types

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

Description

Hi Devs,

I tried to remove some features from the default post types (eg. post-formats) but since both plugins and theme are called after create_initial_taxonomies and create_initial_post_types, i cannot do a thing.

So i suggest to call theses 2 function after calling at least the plugins, if we consider post-types/taxonomies as a plugin "territories".

Attachments (1)

36685.patch (939 bytes) - added by sidati 8 years ago.

Download all attachments as: .zip

Change History (9)

@sidati
8 years ago

#1 follow-up: @websupporter
8 years ago

Haven't checked yet, but does remove_post_type_support() not work? https://codex.wordpress.org/Function_Reference/remove_post_type_support

#2 in reply to: ↑ 1 @sidati
8 years ago

  • Keywords has-patch added

Replying to websupporter:

Haven't checked yet, but does remove_post_type_support() not work? https://codex.wordpress.org/Function_Reference/remove_post_type_support

Actually i'm not only using this for removing features but also for changing other settings such as labels and icon ... etc

P.S. Im transferring the post type post to something else lets say Product

used filter : register_post_type_args

Last edited 8 years ago by sidati (previous) (diff)

#4 @sidati
8 years ago

Beside nothing will work even remove_post_type_support cause create_initial_post_types is called before any plugin or theme :P, so if you remove post-formats using the function remove_post_type_support will not remove the metabox on post editor page

Actually it does work because create_initial_post_types is called again on init action, this is little bit tricky

Last edited 8 years ago by sidati (previous) (diff)

#5 @ocean90
8 years ago

  • Summary changed from Cannot edit the default args og default post types to Cannot edit the default args of default post types
  • Version trunk deleted

#6 @mr_speer
7 years ago

Would it make sense to allow these default post/taxo args to be filterable? That way altering labels, support, etc. would be a relatively painless process. I feel like as it is now, doing something as simple as changing "Posts" to "News" is needlessly complicated.

#7 @johnbillion
7 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Resolution set to fixed
  • Status changed from new to closed

The register_post_type_args (and register_taxonomy_args) filter has been available since WordPress 4.4 (see #17447). As mentioned above, the default post types are re-registered on the init hook, so these filters also apply to default post types and taxonomies.

Example usage:

add_filter( 'register_post_type_args', function( array $args, $name ) {
	if ( 'post' === $name ) {
		$args['labels']['menu_name'] = 'News';
	}
	return $args;
}, 10, 2 );

Please feel free to re-open if something about these filters is not working as expected.

#8 @johnbillion
7 years ago

  • Milestone 4.4 deleted
  • Resolution changed from fixed to worksforme
Note: See TracTickets for help on using tickets.