如何获取gallery中使用的图像的ID?使用$gallery = get_post_gallery_images( $post );
我只得到一个带有缩略图url的字符串,没有基本上所有内容都需要的图像ID。
https://codex.wordpress.org/Function_Reference/get_post_gallery_images
(最后,我正在寻找一种方法来获取gallery中使用的所有图像的图像对象,我正在Codex中搜索,但找不到它)如何获取gallery中使用的图像的ID?使用$gallery = get_post_gallery_images( $post );
我只得到一个带有缩略图url的字符串,没有基本上所有内容都需要的图像ID。
https://codex.wordpress.org/Function_Reference/get_post_gallery_images
(最后,我正在寻找一种方法来获取gallery中使用的所有图像的图像对象,我正在Codex中搜索,但找不到它)您正在编写模板吗?函数中的过滤器。php还是插件?一种简单的方法是get_post_gallery
将第二个参数设置为false,以便返回对象而不是html。
if ( get_post_gallery() ) :
//Get the gallery object
$gallery = get_post_gallery( get_the_ID(), false );
//Form an array with the found ids
$gallery_attachment_ids = explode( \',\', $gallery[\'ids\'] );
endif;
我有一个自定义的帖子类型,叫做book-list.我通过以下方式从链接获取帖子类型类别的名称$_GET[\'w_year\'] 正确地我需要获取该类别名称的ID我不在柱子里或其他什么地方。只需要知道用户希望在哪一年工作的id。