WordPress根据页面标题获取页面对象函数:get_page_by_title

WordPress函数get_page_by_title根据页面标题获取页面对象,如果有相同名称标题的页面,则返回最早发布的页面。 get_page_by_title( string $page_title, string $output = OBJECT, string|array $post_type = 'page' ) 函数参数$page_tit …

WordPress根据页面路径获取页面对象函数:get_page_by_path

WordPress函数get_page_by_path根据页面路径获取页面对象 get_page_by_path( string $page_path, string $output = OBJECT, string|array $post_type = 'page' ) 函数参数$page_path 字符串 页面的路径,不包含域名部份,例如: /about/contact $output 字符串 …

WordPress获取页面链接函数:get_page_link

WordPress函数get_page_link用于获取指定页面的链接 get_page_link( int|WP_Post $post = false, bool $leavename = false, bool $sample = false ) 函数参数$post 整数或WP_Post 页面ID $leavename 布尔值,默认值:false 是否返回 …

WordPress获取祖先ID函数:get_ancestors

WordPress函数get_ancestors可以用于获取分类的祖先ID,或页面的祖先ID,包括所有的上级。 get_ancestors( int $object_id, string $object_type = '', string $resource_type = '' ) 函数参数$object_id 整数 对象ID $object_type 字符 …

WordPress获取所有页面ID函数:get_all_page_ids

WordPress函数get_all_page_ids用于获取所有页面的ID,以数组的形式返回结果,该函数没有任何参数。 get_all_page_ids() 函数使用示例以下示例代码输出所有页面的链接列表: $page_ids = get_all_page_ids(); echo & …

WordPress修改文章状态为公开:wp_publish_post

WordPress函数wp_publish_post用于修改文章的状态为publish wp_publish_post( int|WP_Post $post ) 函数参数$post 整数 要修改的文章ID 扩展阅读wp_publish_post()函数位 …

WordPress更新文章函数:wp_update_post

WordPress函数wp_update_post用于更新现有的文章 wp_update_post( array|object $postarr = array(), bool $wp_error = false, bool $fire_after_hooks = true ) 函数参数$postarr 数组 可用值参考wp_insert_post()函数的$pos …

WordPress插入文章函数:wp_insert_post

WordPress函数wp_insert_post用于插入一篇新的文章。 wp_insert_post( array $postarr, bool $wp_error = false, bool $fire_after_hooks = true ) 函数参数$postarr 数组 ID:文章的ID,如果传递0以外的值,则更新相应ID的文 …

WordPress删除文章函数:wp_delete_post

WordPress函数wp_delete_post用于删除指定ID的文章 wp_delete_post( int $postid, bool $force_delete = false ) 函数参数$postid 整数 要删除的文章ID $force_delete 布尔值,默认值:false 是否绕过回收站直接删除 …

WordPress判断文章类型是否支持层级函数:is_post_type_hierarchical

WordPress函数is_post_type_hierarchical用于判断指定文章类型是否支持层级。 is_post_type_hierarchical( string $post_type ) 函数参数$post_type 字符串 文章类型名称 扩展阅读is_pos …