WordPress获取登录用户信息函数:get_currentuserinfo
WordPress函数get_currentuserinfo用于获取当前登录用户信息,自4.5.0版本起,已不建议使用get_currentuserinfo,请换用wp_get_current_user()函数。 函数返回值get_currentuserinfo()函数返回WP_User实例,包含了用户的各字段信息。 …
WordPress函数get_currentuserinfo用于获取当前登录用户信息,自4.5.0版本起,已不建议使用get_currentuserinfo,请换用wp_get_current_user()函数。 函数返回值get_currentuserinfo()函数返回WP_User实例,包含了用户的各字段信息。 …
WordPress函数wp_get_current_user用于获取当前已登录用户的对象数据,该函数没有可用的参数。 wp_get_current_user() 函数返回值wp_get_current_user()函数返回WP_User实例,包含了用户的各字段信息。 …
WordPress函数wp_set_current_user用于更改当前登录的用户,例如管理员代管用户的场景。 wp_set_current_user( int|null $id, string $name = '' ) 函数参数$id 整数 用户ID $name 字符串 如果无法提供用户ID,也可以使用用户登录名。 …
WordPress函数set_current_user用于更改当前登录用户,在一些需要代登录的场景比较有用。自WordPress 3.0.0版本起,已不建议使用set_current_user()函数,应该使用wp_set_current_user()函数。 …
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 字符串 …