如果您使用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();
}
}
未经测试,但应能正常工作。