WordPress获取用户文章数量函数:get_usernumposts
WordPress函数get_usernumposts用于获取用户发表的文章总数,自3.0.0版本起,已不建议使用get_usernumposts(),请换用count_user_posts()函数。 …
WordPress函数get_usernumposts用于获取用户发表的文章总数,自3.0.0版本起,已不建议使用get_usernumposts(),请换用count_user_posts()函数。 …
WordPress函数get_profile根据登录用户名(例如:admin)获取用户信息,该函数自3.0.0版本起,已不推荐使用,请使用get_the_author_meta()函数。 …
WordPress函数get_the_author用于获取作者的名称,返回名称为个人资料中“公开显示为”选项设置。 get_the_author( string $deprecated = '' ) 函数参数$deprecated 字符串,默认为空 自2.1.0版本起,不再支持该参数。 …
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 字符串,默认值:null 当文章使用More标签分隔摘要内容时,get_the_content()函数只返回摘要内容。如果还有更多内容未能显示,将输出一个“更多”按钮,可以提供一个文本值来替换默认的更多按钮文本。 …
WordPress函数get_the_ID一般用在主循环The Loop中,以获取当前Post ID。也可以在文章模板、页面模板中使用,在这些页面即使主循环之外也能获取到当前页面的ID。 get_the_ID() 函数使用示例<?php $id = get_the_ID(); $dropdown = "<select name='dropdown-".$id."' >"; $dropdown .= "<option id='option-" . $id ."'>Option</option>"; $dropdown .= "</select>"; ?> 扩展阅读get_the_ID()函数位于:wp-includes/post-template.php …
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 ) 函数参数$id 字符串 …
WordPress函数wp_trim_excerpt生成长度为55字符的文章摘要。 wp_trim_excerpt( string $text = '', WP_Post|object|int $post = null ) 函数参数$text 字符串 摘要文字,如果为空,则从文章内容中提取。 $post 整数或WP_Post对象 …
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 字符串或数组 分类/标签的名称 $taxonomy 字符串,默认值:post_tag …
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_tag 分类法名称,默认为标签。可选值:category …
WordPress函数wp_set_post_tags用于给文章分配标签。 wp_set_post_tags( int $post_id, string|array $tags = '', bool $append = false ) 函数参数$post_id 整数 文章的ID $tags 字符串或数组 要分配的标签名称,分配多个标签时,使用一个包含各标签名称的数组。 …