As Milo ( and your errors ) point out: you’re passing an array where a string is expected. According to WP_Query tag parameter
Show posts associated with certain tags.
- tag (string) – use tag slug.
To get around this you just need to pass a comma separated string:
function custom_tags( $query ) {
$query->set( 'tag', 'custom,general' );
}
add_action( 'pre_get_posts', 'custom_tags' );
Related Posts:
- Looping through WP_Post Object
- Displaying Only Certain Tags in Loop
- How can I add multiple ‘tax_query’ arrays via a loop?
- Checking array against author id in loop
- List posts that don’t have a specific tag?
- Filtering a function’ output for a new continued function
- How to get the last category name of a child category?
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Only show first image in foreach loop
- Get all posts as an array ID => Name
- Limit tags shown in post
- in_array not working on dev server but works on localhost
- ACF – Get ID of relationship field in flexible content
- Show the subcategory name based on current product
- View tag description on page
- Get a list of tags present in a paged front page
- Display product attributes for current product
- WP_Post is not from correct array
- Create Customization Controls from Array
- Blog posts repeat
- How to add condition in wordpress loop? [closed]
- Woocommerce : Can’t get product info in loop
- How to set variable, pass it to a partial file and remove it after?
- how to refresh div on template part?
- Exclude posts based on meta value
- Alert Bar section within WP loop is displaying even though there are no posts
- remove post that has no content
- Display category name only once inside loop
- Adding Taxonomy Image to taxonomy loop [closed]
- Can’t find infinite loop cause
- How do I Turn This Into An if statement?
- Load wordpress content in other domain
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- Checkbox doesn’t stay checked, conten
- If tag equals then show else show
- Way to bulk make all my tags lowercase?
- post thumbnail, conditions, else wont work
- Widgets in the loop if active
- Pull Tags But Not as Links
- Adding Meta Tags to a Post using its Tags, Excerpt and content
- Alter required message using comment form api
- Changing the_posts_navigation() html output
- Can we count the WordPress Loop
- Advanced Custom Fields – display label and value only if value entered
- Get post id within comments loop
- meaning of (array)function()
- Syntax error when I try to insert my loop into an unordered list? [closed]
- WP_Query fails despite having 1 post
- Grouping posts by a custom meta value
- Edit the_category (); for a hierarchical display
- Need to put a script above tag in header.php – WP 5.7.1
- wp_force_remove_style’ not found
- Add content after the first post in WP Loop
- wp_query get the 2nd post
- Loop stopped working
- How to get post ID in a Page?
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- How can I access string value in an array?
- How to use if statement in an array? [closed]
- Custom Pagination is Broken
- Display an image if odd number of posts in grid
- How to loop through all the attached images in a post, and get their url one by one
- How to array only one key from another array
- Use Tags to initiate Search
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- PHP Warning: strip_tags() expects parameter 1 to be string?
- Output meta into arrays
- Trying to prepend a Hashtag symbol to the_tags links [closed]
- Store post content in a php variable and output them using for loop
- How to add div blocks after certain set of post
- Get html data with javascript to php array and store to wordpress database
- Echo a shortcode div after every 3 posts
- How to avoid duplicates when creating recent network posts
- How to overwrite orderby with add_query_var
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- How do I create a numbered list with PHP? [closed]
- Why in my theme I can’t see all the statics content under the posts?
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- stripping tags from excerpt in WordPress is not working
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Is the 404 page automatically displayed if a loop returns nothing?
- How do I remove a category from a wordpress loop>
- How to use array in function to get only value I want
- Error while setting role
- Get categories names as an array to use it in theme settings
- variable value disappears in a second loop
- Last class on last headline?
- Show recent posts starting at a specific number archive
- get_the_ID() in the footer returns wrong value
- How to say if meta_value is greater than 0 in an array?
- How to use two meta_compare in an array?
- Warning: in_array() null given in PHP function
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- WordPress query undefined offset in loop
- Foreach loop inside an array_merge
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- How to unlink all posts from tracking same amount of views
- Issue with custom loop in Archive page
- Loop over Array and get the distinct ids
- How to access or parse key/values that have “string”