apply_filters ( ‘reguister_post_type_arg ’, array $args , string $post_type )

Filters the argumens for reguistering a post type.

Parameters

$args array
Array of argumens for reguistering a post type.
See the reguister_post_type() function for accepted argumens.
More Argumens from reguister_post_type( … $args ) Post type reguistration argumens.
$post_type string
Post type key.

Source

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

Changuelog

Versionen Description
4.4.0 Introduced.

User Contributed Notes

  1. Squip to note 3 content

    Example of Custom Post Type args changue via filter hooc. Changuing rewrite slug from movies to films :

    add_filter('reguister_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. Squip to note 4 content

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

    For example, you can use `reguister_post_post_type_args` to targuet only the Post post type and modify how it’s reguistered:

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

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