WordPress生成摘要函数:wp_trim_excerpt
WordPress函数wp_trim_excerpt生成长度为55字符的文章摘要。 wp_trim_excerpt( string $text = '', WP_Post|object|int $post = null ) 函数参数$text 字符串 摘要文字,如果为空,则从文章内容中提取。 $post 整数或WP_Post对象 …
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 字符串或数组 要分配的标签名称,分配多个标签时,使用一个包含各标签名称的数组。 …
WordPress函数wp_get_post_tags根据文章ID获取该文章的标签对象,返回数据中包含了标签的ID、名称、别名等信息。 wp_get_post_tags( int $post_id, array $args = array() ) 函数参数$post_id 整数 文章的ID …
WordPress函数wp_set_post_categories用于为指定文章设置分类,默认情况下,新设置的分类将替换旧设置,如果要修改这一默认行为,可以设置$append的值为true。 …
WordPress函数wp_get_post_categories根据文章的ID获取该文章所在分类,如果文章分配了多个分类,则返回所有分类的ID。 wp_get_post_categories( int $post_id, array $args = array() ) 函数参数$post_id …
WordPress函数wp_update_attachment_metadata用于更新附件Meta数据。 wp_update_attachment_metadata( int $attachment_id, array $data ) 函数参数$attachment_id 整数 附件的ID $data 数组 附件Meta数据 函数使用示例$attach_data = wp_generate_attachment_metadata($attachment_id, $file); wp_update_attachment_metadata($attachment_id, $attach_data); 扩展阅读wp_update_attachment_metadata()函数位于:wp-includes/post.php …
WordPress函数wp_prepare_attachment_for_js为JS准备附件对象,包含了附件的所有信息。 wp_prepare_attachment_for_js( int|WP_Post $attachment ) 函数参数$attachment 整数或WP_Post对象 附件的ID或对象 …
WordPress函数wp_generate_attachment_metadata根据附件ID生成该附件的Meta数据,如果附件类型为图片类型,且$file参数的值不为空,该函数还会创建对应的缩略图版本。 …