有没有办法阻止特色图片出现在帖子的图库中?
e、 g.在管理员中编辑帖子的图库时,特色图片不存在。
有没有办法阻止特色图片出现在帖子的图库中?
e、 g.在管理员中编辑帖子的图库时,特色图片不存在。
好的,我也遇到了同样的问题,只是通过在短代码中添加一个“排除”字段来解决了这个问题。就像这样。。。
[gallery link="file" columns="4" orderby="title" exclude="1050"]
您只需提取不想显示的文件的ID号即可。此操作无需向主题添加任何函数或编辑。我同意@janw的回答。
我想进一步补充如下:
您可以编辑单个模板以自动显示库,而无需手动插入库快捷码。打开你的单曲。php文件,并在循环中复制以下代码行,在循环中显示库:
<?php $id = get_post_thumbnail_id(get_the_ID()); // gets the post thumbnail ID ?>
<?php echo do_shortcode("[gallery exclude={$id}]"); // insert the gallery without the thumbnail ?>
如果您使用gallery
shortcode 您可以添加exclude
带特征图像id的参数,以将其排除。
如果要动态执行,我建议使用post_gallery
滤器
<?php // add to functions.php
add_filter (\'post_galley\', \'exclude_featured_img\');
function exclude_featured_img($attr)
{
if (!isset($attr[\'exclude\']) || empty($attr[\'exclude\'])) {
return $attr[\'exclude\'] = get_post_thumbnail_id();
} else {
return $attr[\'exclude\'] = $attr[\'exclude\'] . \',\' . get_post_thumbnail_id();
}
}
未经测试,但应能正常工作。我希望能够在主页上的jquery滑块中使用媒体库中的图片,以便其他人无需硬编码即可轻松更新图片。我在帖子上贴了一堆照片,并尝试了这个<?php $image_query = new WP_Query(array(\'name\'=>\'slider-images\')); while ( $image_query->have_posts() ) : $image_query->the_post(); $args = array( \'post_typ