如何阻止 PBS 显示
您可以使用 pbs_is_editable_by_user 过滤器来阻止 PB Sandwich 在前端显示。
例如,要阻止 PB Sandwich 在别名为 slider 的自定义文章类型中显示,您可以在 functions.php 中添加这段代码:
add_filter( 'pbs_is_editable_by_user', 'stop_pbs_in_sliders' );
function stop_pbs_in_sliders( $editable ) {
if ( is_singular( 'slider' ) ) {
return false;
}
return $editable;
}
要针对特定页面/文章阻止 PB Sandwich,可以使用文章 ID 进行判断:
add_filter( 'pbs_is_editable_by_user', 'stop_pbs_for_123' );
function stop_pbs_for_123( $editable ) {
global $post;
if ( is_singular() && ! empty( $post ) ) {
if ( '123' === $post->ID ) {
return false;
}
}
return $editable;
}