我创建了一个MU插件,它只显示循环中某些标记的帖子,如下所示:
function custom_tags( $query ) {
$query->set( \'tag\', array( \'custom\', \'general\' ) );
}
add_action( \'pre_get_posts\', \'custom_tags\' );
当我移除数组并只检查一个标记时,它工作得很好,但是如何让它像我在上面尝试的那样处理多个标记呢?
我得到的错误是:
Warning: strpos() expects parameter 1 to be string, array given in /srv/users/s/wp-includes/query.php on line 1966
Warning: preg_split() expects parameter 2 to be string, array given in /srv/users/s/wp-includes/query.php on line 1967
更新的代码:
$current = substr($_SERVER[HTTP_HOST], 0, -4);
function custom_tags( $query ) {
$query->set( \'tag\', \'general,{$current}\' );
}
add_action( \'pre_get_posts\', \'custom_tags\' );