apply_filters( 'register_post_type_args', array $args, string $post_type )

Filters the arguments for registering a post type.


$args array
Array of arguments for registering a post type.
See the register_post_type() function for accepted arguments.
More Arguments from register_post_type( ... $args ) Post type registration arguments.
$post_type string
Post type key.

Top ↑


File: wp-includes/class-wp-post-type.php. View all references

$args = apply_filters( 'register_post_type_args', $args, $this->name );

Top ↑


Version Description
4.4.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content

    Example of Custom Post Type args change via filter hook. Changing rewrite slug from movies to films:

    add_filter('register_post_type_args', 'movies_to_films', 10, 2);
    function movies_to_films($args, $post_type){
        if ($post_type == 'movies'){
            $args['rewrite']['slug'] = 'films';
        return $args;
  2. Skip to note 2 content
    Contributed by mrwweb

    You can also use `register_{$post_type}_post_type_args` to target a specific post type.

    For example, you can use `register_post_post_type_args` to target only the Post post type and modify how it’s registered:

    add_filter( 'register_post_post_type_args', 'wpdocs_default_posts_template' );
     * Add default template for new Posts with the Featured Image as the first block
    function wpdocs_default_posts_template( $args ) {
        $args['template'] = array(
            array( 'core/post-featured-image', array( 'align' => 'center' ) )
        return $args;

You must log in before being able to contribute a note or feedback.