创建必用插件把它放进去<docroot>/wp-content/mu-plugins/selective-posts.php
以下应该是selective-posts.php
筛选特定帖子。
function golfclubs_tag( $query ) {
if ( $_SERVER[\'HTTP_HOST\'] === \'www.golfclubreviewdomain.com\' ) {
$query->set( \'tag\', \'golfclubs\' );
}
}
add_action( \'pre_get_posts\', \'golfclubs_tag\' );
通过这种方式,它将过滤整个站点中特定域的所有查询,并过滤带有特定标签的帖子。
如果要在查询中添加另一个标记,可以按如下方式编辑上述代码:
function golfclubs_tag( $query ) {
if ( $_SERVER[\'HTTP_HOST\'] === \'www.golfclubreviewdomain.com\' ) {
$query->set( \'tag\', \'golfclubs,general\' );
}
}
add_action( \'pre_get_posts\', \'golfclubs_tag\' );