Ok, so after deeper research I’ve found out that values of some custom fields created by ACF are stored in MySQL database with some additional information like a:5:{i:0;s:6:"Aerial";i:1;s:6:"Nature";i:2;s:4:"Nude";i:3;s:6:"People";i:4;s:8:"Wildlife";}
. This happens when a custom field can store multiple values (like chechboxes).
So I’ve edited part of my query from this:
if( !empty($_GET[‘theme’]) )
{
$contestTheme = explode(‘,’, $_GET[‘theme’]);
$contestThemeArray = array(
'key' => 'theme',
'value' => $contestTheme,
'compare' => 'IN',
);
}
To this:
if( !empty($_GET['contest_theme']) )
{
$contestTheme = explode(',', $_GET['contest_theme']);
$contestThemeArray = array('relation' => 'OR');
foreach ($contestTheme as $theme) {
$contestThemeArray[] = array(
'key' => 'contest_theme',
'value' => $theme,
'compare' => 'LIKE',
);
}
}
Related Posts:
- Extending the search context in the admin list post screen
- Advanced search form with filters for custom taxonomies and custom fields
- How can I change the admin search posts fields?
- Development of a WordPress Search Plugin – Best Practices
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Search multiple custom fields by using meta_query
- How do I Paginate Search Results for Custom Post Types?
- Query custom post type by custom field
- Search that will look in custom field, post title and post content
- Search everything (posts, pages, tags, cpt, meta)
- Search Custom Post Type with all meta attached?
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Backend search; include CPT meta?
- Custom Search | Wrong output & question
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- WP insert post PHP function dynamically generated Custom Fields
- Include different loop templates in search query
- Having trouble with custom date field for CPT query (WordPress)
- Sort posts based on multiple custom fields
- Search Custom Post Type Custom Fields
- Custom Fields vs Separate Table
- Conditional to modify query results
- query posts and custom post type with meta key
- Including Custom Meta with posts_where query
- search also in taxonomy, tags and custom fields
- How to stick custom post at the top in search results
- Filter custom posts using auto populated dropdown selectors
- Querying Two Custom Post Types with OR Not Working
- Including metaboxes from custom post types in global search — continued
- First custom field value (out of several) displayed twice after query
- Displaying and searching Custom Posts
- Searching Custom Fields
- filter search custom field query
- How to let users choose where to search for posts?
- Add custom attributes to a post
- How to conditionally add Custom Post Type to Front Page
- Custom Taxonomy Search result page
- search custom post type by custom fields on front end
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- Custom Query: If One Post Object Field Value Is The Same As Another
- Pagination on search results page
- Best way to create a search for custom post type by custom field values
- Search CPT Title AND Meta
- Change search query in wordpress custom post type
- WP Query from two Custom Post type fields as statement
- Using OR relation in meta_query to check for a value before sorting by another
- Meta query and compare “!=” not working as expected
- Creating a custom WP query for a Custom Post Type
- How do I query with multiple custom fields orderby in same column?
- Advanced search form with multiple custom fields
- Search facility with directories
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Show first posts with custom field not empty and order all by title
- Conditional posts in WP_query for search
- Search form to find custom meta box generated data
- Is it good practice to search for custom posts based on custom field values?
- Filter CPT based on meta box value using Flexible Posts widget?
- Advanced search form with filters for custom taxonomies and custom fields
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- WordPress search results
- Filter Custom post type by another Custom post type
- Get Posts ordered by a date custom meta field
- echo value from ‘select’ field type into page template using cmb2?
- How to solve suspected memory issue in custom WordPress loop?
- Query multiple taxonomy in Custom Post Type
- How to filter search results by post type?
- Get next and previous 3 posts in a term in single post page
- Bulk Update Custom Fields for Custom Post Types
- Displaying All Posts of a Custom Post Type in WordPress Multisite Backend
- Custom posts type for individual pages?
- Get Post Terms of Current Post (selected taxonomy term) – How to get only the taxonomy value and not “Array ( [0] => taxonomy term )” in the frontend?
- WP Query ‘posts_per_page’
- Custom Post Type Metadata Not Saving
- How to migrate Custom Field Template to a WordPress Multisite
- Create query for both custom post type and category
- Custom Post type showing up in loop, regular posts are not showing up
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- How do I ensure that post_type and Taxonomy use the same slug?
- How to make an API call to a custom post type but filtering by meta value?
- Custom Form / Search with Custom Post Type Data
- Custom Column in CPT admin table not updated after Quick Edit save
- Display Custom Field or Custom Taxonomy in front page /post/product
- WP_Query for custom taxonomies showing posts from non-specified terms?
- WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category
- Search in multiple specific post types
- custom search form for custom post
- Custom post url in search.php isn’t the correct rewrited url
- How to delete comma from the end of results? [closed]
- Publish post and create additional posts with same content
- Converting a checkbox filter for custom fields to a dropdown
- How do I get a nested query to only display content that the main query outputed
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- How to show animal lineage/pedigree in WordPress?
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- custom post-type query just returns two posts
- Order custom post type is beign ignored
- Display ACF object field data using Elementor Custom Query
- Sortable admin columns ordering from custom fields isn’t combine com search and Dropdown filter