您可以使用option_default_post_format
过滤器:
add_filter( \'option_default_post_format\', \'slimline_default_post_format\' );
/**
* Posts of post_type_1 will be asides by default, but all other post types
* will be the default set on the Settings > Writing admin panel
*/
function slimline_default_post_format( $format ) {
global $post_type;
return ( \'post_type_1\' === $post_type ? \'aside\' : $format );
}
如果要为多个自定义帖子类型设置过滤器,我会编辑该函数以使用switch语句,如下所示:
function slimline_default_post_format( $format ) {
global $post_type;
switch( $post_type ) {
case \'post_type_1\' :
$format = \'aside\';
break;
case \'post_type_2\' :
$format = \'quote\';
break;
}
return $format;
}