Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
set_post_format() - 为文章指定格式 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / set_post_format()

set_post_format( int|object $post, string $format )

为文章指定格式


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "fbd33194a5ce13c433ddeb80052c4cdc" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "c662a3ca6b84e8f01cc3765430bbe052" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "6f1a738255000cf2c8ba3882fd6e44da" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

format 格式

postmore...

setmore...


参数

$post

(int|object) (必填) 要为其指定格式的文章。

$format

(string) (必填) 要指定的格式,使用空字符串或数组从文章中删除所有格式。


返回

(array|WP_Error|false) 成功时返回受影响的 term ID 数组,出错返回 WP_Error


说明

有关支持的格式,请参阅文章格式页。



源码

查看源码 官方文档


更新日志

版本描述
3.1.0开始引入

使用示例

  • 示例1

    基本示例

    <?php
    /*
     * Set the post format of a post (in the loop).
     */
    
    set_post_format($post->ID, 'gallery' ); //sets the given post to the 'gallery' format
    
    ?>