1. 首页
  2. WordPress 函数手册

gallery_shortcode()

gallery_shortcode( array $attr )

生成库快捷方式输出。
Builds the Gallery shortcode output.

目录锚点:#说明#参数#返回#源码#笔记


说明(Description)

这实现了在帖子上显示WordPress图片的Gallery快捷方式的功能。


参数(Parameters)

参数 类型 必填 说明
$attr (array) 必需
Attributes of the gallery shortcode. ‘order'(string) Order of the images in the gallery. Default ‘ASC’. Accepts ‘ASC’, ‘DESC’. ‘orderby’(string) The field to use when ordering the images. Default ‘menu_order ID’. Accepts any valid SQL ORDERBY statement. 可选
‘itemtag'(string) HTML tag to use for each image in the gallery. Default ‘dl’, or ‘figure’ when the theme registers HTML5 gallery support. ‘icontag’(string) HTML tag to use for each image’s icon. Default ‘dt’, or ‘div’ when the theme registers HTML5 gallery support. 可选
‘columns'(int) Number of columns of images to display. Default 3. ‘size’(string | array) Size of the images to display. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default ‘thumbnail’. 可选
‘include'(string) A comma-separated list of IDs of attachments to include. Default empty. ‘exclude’(string) A comma-separated list of IDs of attachments to exclude. Default empty. 可选

返回(Return)

(string)要显示库的HTML内容。


源码(Source)


更新版本 源码位置 使用 被使用
2.5.0 wp-includes/media.php:1860 1 function 18

笔记(Notes)

基本示例

gallery_shortcode() 为WP2原创文章,链接:https://www.wp2.cn/functions/gallery_shortcode/