Thats because you got the meta_query wrong. Check documentation in Codex
Your query should be:
$args = array(
'posts_per_page' => 30,
'paged' => $paged,
'post_type' => 'post',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'post_state',
'value' => $stateName,
'compare' => '=' // not necesary by default is "="
)
)
);
Basically you need to pass inside the meta_query array, another array with the key and value. Also $stateName should be a var.
Related Posts:
- Consistent and Admissible Heuristics
- How do you make Vim unhighlight what you searched for?
- How to create live autofill search?
- Empty search input returns all posts
- How to search for users based on added user metadata
- Search by Post ID and display content of the post in search result
- WP User Query with search columns and meta query
- Get user role by using user_id in buddypress
- Turning Broken URLs Into Search Terms?
- Create multiple Search functions for posts / custom post types and everything
- Set default text for the_search_query();
- How to add WooCommerce SKU to search query?
- Which template holds what to display when search returns nothing
- Search form with Category and Sub Category
- WordPress search not searching pages’ content
- How to change users smart quotes to dumb quotes in search bar?
- Make Search Function include subdomain (blog.ourwebsite.com)
- Replace default WordPress search behavior with Sphinx
- How to disable WordPress Search from Url?
- More than one search results page template
- Changing search slug from + to – (hyphen)
- Force is_search to always TRUE
- Add search box to page
- Plugin: Events Manager – Search by start date only
- Worried I have a funky .htaccess for WP site in light of strange search engine behavior
- Quick and Easy way to Add Search to the P2 Theme?
- Get PDF in media by ID
- Display post matching the exact search term
- Show only “Pages” – not posts – on search page
- remove post edit.php search form and replace with my own
- Get most searched keywords in WordPress
- Search bar in table in wordpress
- Where does the Yoast SEO plugin set the Open Graph metadata?
- search filter add priority to post_type and add order to some post_type
- How do I add custom fields data to a search index?
- Empty search results return soft 404
- meta_query issue with multiple numerics
- How do I search events between two set dates inside WP?
- searchform.php :: pass second query string variable with same value as ?s=
- Limit search to custom field
- How can I get a traceback on function calls?
- What does wordpress search, search?
- How to have search results page sorted by post date
- Search Results Page outputs HTML code
- Custom Query Content Filtering
- Search buddypress groups with querystring in url
- Make search result display 1 Company or 2 Companies
- Displaying number of search results for each post type
- Search not working. Appending a “
- Search posts by Tag
- Search returns everything if search term has a space
- BuddyPress – Search members by name and also by username
- Add Google custom search to wordpress.com [closed]
- Include results with tags relevant to the search keyword with JSON rest API v2
- Search function does not work on mobile devices
- Changing the ORDER BY in WordPress default search function
- How Can I Make Dynamic Search Form While Converting Html To WordPress?
- Get the search element only on 404
- Specific website content
- Second page (and next) of search results redirects me to the home page
- search results to a variable in search.php
- Enhancin 404 to contain a search from URL
- Load search results into a div
- Search using ACF repeater
- Search in posts’ attachments: title, caption, description
- Exclude certain Gutenberg blocks from search results
- How to order search results so a specific page appears first when user searches for a particular word?
- make link to search page
- Search results thumbnails different size
- searchform.php not included by get_search_form when using wp_dropdown_categories
- WordPress User Search Based on Latitude and Longitude
- Remove gray header on Search Result page on WordPress
- How do i get The dropdown to have the value of the sub cat and custom fields
- Why are archived pages showing up in searches and able to be accessed?
- Problem with search results page
- Enable query based wordpress search ?s=
- Partial searches for wp_usermeta
- Search terms in other language turns out to question mark and symbols
- Adding thumbnail to search results & changing content.php
- Create a custom and powerful search form
- How to search for categories instead of products in Woocommerce?
- Search results show only content by admin post authors
- Buddypress Activity search with OR query instead of AND
- search form display no result
- How to exclude one post format from search result?
- Help with WordPress search
- Custom Search Form WP_Meta_Query – Filtering Custom Fields
- Page/Post path in Search Results
- Search not displaying results
- Make search result returned only from tags! [duplicate]
- WordPress search form and input type=”image”
- How to search pdf attachment?
- How do I find a shortcode stored in wordpress?
- Return excerpt on Search
- Attached file how can i work the wp_query to search for related names
- Custom WordPress Excerpt within terms
- WordPress Search – Reject partial matches
- Need help to be able to searching by tag and title
- Wp query search built out of 4 terms?
- Ivory Search error