WordPress根据登录用户名获取用户信息函数:get_profile

WordPress函数get_profile根据登录用户名(例如:admin)获取用户信息,该函数自3.0.0版本起,已不推荐使用,请使用get_the_author_meta() …

WordPress获取作者函数:get_the_author

WordPress函数get_the_author用于获取作者的名称,返回名称为个人资料中“公开显示为”选项设置。 get_the_author( string $deprecated = '' ) 函数参数$deprecated 字符串,默认为空 自2.1 …

WordPress获取文章内容函数:get_the_content

WordPress函数get_the_content用于获取文章内容,通常用在主循环The Loop中。 get_the_content( string $more_link_text = null, bool $strip_teaser = false, WP_Post|object|int $post = null ) 函数参数$more_link_text 字符串,默认 …

WordPress获取当前Post ID函数:get_the_ID

WordPress函数get_the_ID一般用在主循环The Loop中,以获取当前Post ID。也可以在文章模板、页面模板中使用,在这些页面即使主循环之外也能获取到当前页面的ID …

WordPress添加元数据设置项函数:add_meta_box

WordPress添加元数据设置项函数:add_meta_box

WordPress函数add_meta_box用于为指定文章类型添加元数据设置项,例如可以为文章添加一个关键词设置单元。 add_meta_box( string $id, string $title, callable $callback, string|array|WP_Screen $screen = null, string $context = 'advanced', string $priority = 'default', array $callback_args = null ) 函数参数$i …

WordPress生成摘要函数:wp_trim_excerpt

WordPress函数wp_trim_excerpt生成长度为55字符的文章摘要。 wp_trim_excerpt( string $text = '', WP_Post|object|int $post = null ) 函数参数$text 字符串 摘要文字,如果为空,则从文章内容中提取。 $post 整数或WP_ …

WordPress为文章添加分类法函数:wp_set_post_terms

WordPress函数wp_set_post_terms为指定文章添加分类法。 wp_set_post_terms( int $post_id, string|array $tags = '', string $taxonomy = 'post_tag', bool $append = false ) 函数参数$post_id 整数,文章的ID $tags 字符串或数组 分类/标签的名称 …

WordPress获取文章所属分类法函数:wp_get_post_terms

WordPress函数wp_get_post_terms可用于获取指定文章所属的分类法。 wp_get_post_terms( int $post_id, string|string[] $taxonomy = 'post_tag', array $args = array() ) 函数参数$post_id 整数 文章的ID $taxonomy 字符串,默认值:post_t …

WordPress设置文章标签函数:wp_set_post_tags

WordPress函数wp_set_post_tags用于给文章分配标签。 wp_set_post_tags( int $post_id, string|array $tags = '', bool $append = false ) 函数参数$post_id 整数 文章的ID $tags 字符串或数组 要分配的标签名称,分配多个标签 …

WordPress获取文章所属标签对象函数:wp_get_post_tags

WordPress函数wp_get_post_tags根据文章ID获取该文章的标签对象,返回数据中包含了标签的ID、名称、别名等信息。 wp_get_post_tags( int $post_id, array $args = array() ) 函数参数$post_id 整数 文 …