wpseek.com
WordPress开发者和主题制作者的搜索引擎
set_post_format › WordPress Function
Since3.1.0
已弃用n/a
› set_post_format ( $post, $format )
| 参数: (2) |
|
| 返回: |
|
| 定义在: |
|
| 文档: |
Assign a format to a post
Related Functions: get_post_format, has_post_format, get_post_format_link, get_post_format_slugs, get_post_format_string
源码
function set_post_format( $post, $format ) {
$post = get_post( $post );
if ( ! $post ) {
return new WP_Error( 'invalid_post', __( 'Invalid post.' ) );
}
if ( ! empty( $format ) ) {
$format = sanitize_key( $format );
if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs(), true ) ) {
$format = '';
} else {
$format = 'post-format-' . $format;
}
}
return wp_set_post_terms( $post->ID, $format, 'post_format' );
}