You need an additional parameter meta_query
in the WP_Query
arguments.
$query_args = [
'posts_per_page' => -1,
's' => esc_attr( $_POST['keyword'] ),
'post_type' => 'visitor',
'meta_query' => [
'key' => 'visitor-hide',
'value' => 'yes',
'compare' => '!=',
]
]
or in cases like yours (query by single custom field):
$query_args = [
'posts_per_page' => -1,
's' => esc_attr( $_POST['keyword'] ),
'post_type' => 'visitor',
'key' => 'visitor-hide',
'value' => 'yes',
'compare' => '!=',
]
You can find more about custom field parameters in WP_Query
here.
Related Posts:
- How to create a WP_Query to search the Title or Tag?
- How to display custom field on homepage
- How do I dynamically generate args for wp_query?
- Use wp_get_recent_posts with search term
- have_posts() execution failure
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- Can’t search posts using WP_QUERY inside AJAX Function
- Only show search results with if current date is between two dates?
- WordPress pagination not working with search page
- WP Query with custom Shortcode
- Form search query – displaying ACF “Post Object” field as results
- List post by title length
- Search.php gets metadata from first post
- How can I modify this code to make the search box include tags and meta
- Free search and custom taxonomy query not providing the same result
- search.php to search only the post title
- WordPress Search Ajax + Isotope + InfiniteScroll
- Replace a single variable with add_filter
- Using a new WP_Query inside the loop
- meta_query search names when they have middle initials
- Delete post meta by serialized meta value
- Search only for posts with specific metadata?
- Include search tags and users in my search results system
- making a search.php query
- Use custom get results query to show posts WordPress
- How to get to a specific position in wp_query?
- Get category name from custom loop and echo it once
- Can I use HTTP POSTs? Is there a better alternative?
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- How do I implement a .diff changeset from core.trac.wordpress.org locally?
- Looking for most performant way to execute several similar WP queries within shortcodes
- API response to be stored locally
- PHP can I add line numbers to file_get_contents()
- How to get 2 or multiple custom post types in wordpress functions.php
- WP_Query loop, does not display special characters in title correctly
- Remove query string specific key value
- Multiple choice in a custom taxonomy
- If search results empty then execute certain code
- Hide post if matches current month and year
- Count the number of times the search form template gets included on a page
- Displaying theme options in css
- Get the last month with posts using a recursive function…
- Use WP_Query in shortcode
- Creating bulk posts with Youtube videos
- esc_url returns incorrect URL
- Random Default Avatar Function
- How to filter posts by post format “standard” from wp-json api?
- Why is variable not working on custom sql query using wpdb?
- Change Navigation Bar based on logged in or not
- Hide wordpress field if data is empty in post!
- How to query for pages/post depending on slug?
- How to loop for every result found in the_content() when using the search query?
- How can I use wp_query to show all product data using just the products ID?
- Change the site tagline (or similar) based on current page
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- Setting custom canonical urls
- Random order of WP_Query results with highest meta value
- Custom page archive query by url var calling page twice on one of my custom queries?
- WordPress custom slug (endpoint) and compare all links
- database interactions using OOP
- Customizer: Output default value in Customizer CSS
- How to add just one specific page to widget without plugin?
- Remove one value in dismissed_wp_pointers?
- create a select input with menus created on a custom options page
- Taxonomy linked to pages
- How to query for posts with a null or blank post_name?
- get current custom post ID by WP_Query method
- Input type search in Menu
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- How to make a search button that will search my website?
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Using foreach loop breaks
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- WordPress Search Results for Multiple Post Types
- Accessing data from a non-WP database/table within a page content
- Create WP_Query to search for posts by their categories or their parent/child categories
- WordPress blog post url on category page
- wp_query with cat not working
- Changing layout with wp_customise
- WP dynamic featured image – Can’t get second featured image url
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- Converting HTML Template to WordPress Theme
- Extending the WP_Widget_Text class
- How to use an associative array in post__in with WP_Query?
- If Query In Sidebar
- Recent Posts slider, using WP_Query(), loads duplicate sliders
- Selectbox in admin panel function linking to CSS
- Compare post-IDs within WP_Query? (Less than / Greater than)
- Customising the search function?
- Can I install/embed WordPress on a ‘single page’?
- Fastest way to get the comment and ping total count for a post
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- How to use $query->set with post__in?
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- How to check if a meta value has already been assigned to any user?
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- filter default query to show just selected level of child pages in wordpress
- Custom search results page not working with empty search