I created an MU Plugin which will only display the posts from certain tags in the loop like this:
function custom_tags( $query ) {
$query->set( 'tag', array( 'custom', 'general' ) );
}
add_action( 'pre_get_posts', 'custom_tags' );
It works fine when I remove the array and only check for 1 tag, but how do I get it to work with more than 1 tag like I'm trying to above?
The Error I'm getting is:
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
Updated Code:
$current = substr($_SERVER[HTTP_HOST], 0, -4);
function custom_tags( $query ) {
$query->set( 'tag', 'general,{$current}' );
}
add_action( 'pre_get_posts', 'custom_tags' );
WP_Query
.