Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#36685 closed defect (bug) (worksforme)

Cannot edit the default args of default post types

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

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 10 years ago.

Download all attachments as: .zip

Change History (9)

@sidati
10 years ago

#1 follow-up: @websupporter
10 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
10 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 10 years ago by sidati (previous) (diff)

#4 @sidati
10 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 10 years ago by sidati (previous) (diff)

#5 @ocean90
10 years ago

  • Summary Cannot edit the default args og default post types → Cannot edit the default args of default post types
  • Version trunk

#6 @mr_speer
10 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
10 years ago

  • Milestone Awaiting Review → 4.4
  • Resolution → fixed
  • Status new → 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
10 years ago

  • Milestone 4.4
  • Resolution fixed → worksforme
Note: See TracTickets for help on using tickets.