post_category expects an array of term IDs, not a string/term slug
$news_term = get_term_by('name', 'news', 'category');
$term_id = $news_term->term_id;
Now use the terms ID not its slug/name in your query args.
'post_category' => array($term_id),
Related Posts:
- Function to return true if current page has child pages
- Get author full name
- Integrating WordPress to my website, while keeping my own authentication system
- Remove/unset options field from backend Settings->General?
- Display posts by month
- How to preserve PHP modifications while upgrading WordPress?
- Removing jQuery migrate and working with dependencies
- is there a simple way to list every templates / php files used to generate a specific page?
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- WordPress Customizer: How can you have multiple active callbacks on one control?
- Edit postmeta when user changes user role?
- Authenticating to WordPress, using my own authentication two-factor system
- How to add default images into theme customizer image control?
- WordPress Ajax Data problem
- there’s a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?
- Remove all nav menu classes ( but keep useful ones… )
- Add attribute / custom attribute to product in woocommerce
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- wp_insert_post not working
- Displaying theme options in css
- Hide wordpress field if data is empty in post!
- Setting custom canonical urls
- Only show search results with if current date is between two dates?
- database interactions using OOP
- WordPress blog post url on category page
- Changing layout with wp_customise
- Extending the WP_Widget_Text class
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- filter default query to show just selected level of child pages in wordpress
- Trying to build simple deposit code that hooks into woocommerce
- user_profile_update_errors hook not executing
- Saving and Restoring a Canvas on A Individual User Basis
- Extend plugin Class through functions.php
- Menu jumping when calling it via PHP
- Modify custom field input data before creating a new post
- Output custom field value to post string
- need help with existing code showing subpages
- How do I add a custom css to all posts without affecting homepage css? [closed]
- how to show only specific category for a template
- Advanced Custom Fields not displaying
- How to get private property in parent class into extended class?
- Exclude posts with specific metadata from search?
- Warning: Illegal string offset on theme options page [closed]
- Clickable image link sends people to wrong URL
- How to include custom PHP file both in header and footer files
- Check class_exists before class definition / Doxygen problem
- Extract links from content
- Delete or edit postmeta with specific meta_key?
- Integrating Yii2 and WordPress
- get post id from wp_insert_post for get_template_part
- Custom Registration username_exists / email_exists
- After disabling WPML multi currency, the currency is still handled by the WPML
- get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
- PHP Helper Class to create shortcodes
- Reusable code that I can store in the function.php and apply to other templates as need. Dry Code
- Is it possible to add a custom page to a free WordPress site? [closed]
- Is there a hack for using is_page() within the function.php file?
- How to Fix an Archive.php That Displays All Posts?
- Assign Custom classes to every Excerpt
- Make next post button link to random post
- Kohana Frontend, WordPress Backend
- Site DOES NOT LOAD after 3.1 update
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- Customizer control save then return to default
- Create Columns with Custom Walker and CSS Classes
- I need to display posts in subcategory beside posts in main category
- How can I check that the acf field value is not a duplicate when adding a post?
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
- update_user_meta as multiple value but with same meta key
- Inserting a class on before_widget if checkbox is checked
- Delete post meta by serialized meta value
- How to identify which php file a plugin is using on page load?
- Dynamic Banner Text based on Subdomain
- Redirect user role to a specific page on login in a multisite network?
- How to add a full working piece of website already coded, to a large scale Website design project?
- Redirecting the lost password page request when using a custon login page
- Create custom admin page with custom text fields
- Remove specific javascript when viewing page in Customizer?
- Running local copy of an old WordPress site on MAMP
- how to call other plugins once custom post has been inserted
- Customizing WooCommerce with PHP
- Multisite – Display different header content based on which site is accessed
- What image is this pulling?
- How can I customize a WordPress theme before it’s downloaded?
- PHP call div with function
- How to use PHP code with wordpress page
- if is_bbPress register jquery
- Auto create description in post
- error with WP custom form
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- How can I clear the theme mod settings?
- Custom PHP-coding in MU installs
- Date when the custom field was added
- HTML in PHP problem [closed]
- WP Custom tables query
- Can’t send form data to wpdb when URL has query string
- Can’t insert into a database wordpress
- Capture the Selected Radio Button Value between two files in wordpress theme
- Partial refresh in WordPress live preview