尽管看起来很简单,但我不知道为什么以下代码不会从帖子内容中删除第一个图库。
function remove_slider($content){
$c=str_replace(get_post_gallery(),"",$content);
return $c;
}
add_filter("the_content","remove_slider");
提前致谢。
答案 0 :(得分:1)
试试这个
function wpse125903_remove_the_first_gallery( $output, $attr )
{
// Run only once
remove_filter( current_filter(), __FUNCTION__ );
// Override the first gallery output
return '<!-- gallery 1 was here -->'; // Must be non-empty.
}
add_filter( 'post_gallery', 'wpse125903_remove_the_first_gallery', 10, 2 );