WordPress删除文章函数:wp_delete_post
WordPress函数wp_delete_post用于删除指定ID的文章 wp_delete_post( int $postid, bool $force_delete = false ) 函数参数$postid 整数 要删除的文章ID $force_delete 布尔值,默认值:false 是否绕过回收站直接删除 扩展阅读wp_delete_post()函数位于:wp-includes/post.php …
WordPress函数wp_delete_post用于删除指定ID的文章 wp_delete_post( int $postid, bool $force_delete = false ) 函数参数$postid 整数 要删除的文章ID $force_delete 布尔值,默认值:false 是否绕过回收站直接删除 扩展阅读wp_delete_post()函数位于:wp-includes/post.php …
WordPress函数is_post_type_hierarchical用于判断指定文章类型是否支持层级。 is_post_type_hierarchical( string $post_type ) 函数参数$post_type 字符串 文章类型名称 扩展阅读is_post_type_hierarchical()函数位于:wp-includes/post.php …
WordPress函数get_post_type_capabilities用于快速生成文章类型角色权限。 get_post_type_capabilities( object $args ) 函数参数$args 对象 参考register_post_type()函数的参数说明,必须的参数:capability_type、capabilities、map_meta_cap 函数返回值stdClass Object ( [edit_post] => edit_post [read_post] => read_post [delete_post] => delete_post [edit_posts] => edit_posts [edit_others_posts] => edit_others_posts [delete_posts] => delete_posts [publish_posts] => publish_posts [read_private_posts] => read_private_posts [create_posts] => edit_posts ) 函数使用示例$args = array( 'capability_type' => 'post', 'capabilities' => array(), 'map_meta_cap' => false ); print_r(get_post_type_capabilities((object) $args)); 扩展阅读get_post_type_capabilities()函数位于:wp-includes/post.php …
WordPress函数get_post_type_object根据文章类型名称获取文章类型数据,返回的结果参考get_post_types()函数$output值为objects时返回的数据。 get_post_type_object( string $post_type ) 函数参数$post_type 字符串 文章类型 函数使用示例$obj = get_post_type_object( 'post' ); echo $obj->labels->singular_name; 扩展阅读get_post_type_object()函数位于:wp-includes/post.php …
WordPress函数get_post_type_archive_link用于获取指定文章类型的文章列表链接。 get_post_type_archive_link( string $post_type ) 函数参数$post_type 字符串 文章类型 函数使用示例<a href="<?php echo get_post_type_archive_link( 'books' ); ?>">图书列表</a> 扩展阅读get_post_type_archive_link()函数位于:wp-includes/link-template.php …
WordPress函数get_post_types用于获取所有文章类型信息。 get_post_types( array|string $args = array(), string $output = 'names', string $operator = 'and' ) 函数参数$args 数组或字符串 根据传递的参数返回符合条件的文章类型,以下示例只返回post: …
WordPress函数get_post_type获取当前文章或指定文章的文章类型,在The Loop主循环中使用则不需要传递文章ID。 get_post_type( int|WP_Post|null $post = null ) 函数参数$post 整数或WP_Post对象 传递文章ID或WP_Post对象 …
WordPress函数post_type_exists检查文章类型是否存在,如果已存在则返回true。通常在使用函数register_post_type()注册文章类型前应该先使用post_type_exists()函数进行检查。 post_type_exists( string $post_type ) 函数参数$post_type 字符串 文章类型 函数使用示例if ( post_type_exists( 'page' ) ) { echo '文章类型page已存在'; } else { echo '文章类型page不存在'; } 扩展阅读post_type_exists()函数位于:wp-includes/post.php …
WordPress函数set_post_type为指定ID的文章设置文章类型。 set_post_type( int $post_id, string $post_type = 'post' ) 函数参数$post_id 整数 要修改的文章ID $post_type 字符串 文章类型 函数使用示例$post_id = 3546; if ( set_post_type( $post_id, 'page' ) ) { echo "文章{$post_id}的类型现在为page"; } else { echo '无法将文章转换为page'; } 扩展阅读set_post_type()函数位于:wp-includes/post.php …
WordPress函数post_type_supports用于检查自定义文章类型编辑区功能是否支持。 post_type_supports( string $post_type, string $feature ) 函数参数$post_type 字符串 自定义文章类型 $feature 字符串或数组 要检查的功能,例如:title、editor、comments、revisions、trackbacks、author、excerpt、page-attributes、thumbnail、custom-fields、and post-formats …