1st. you need to add post_type to your query, then you need to filter meta_value with LIKE. Finaly, you need to add posts_per_page as -1 to get ALL posts.
$args = array(
'post_type'=> 'books',
'meta_query' => array(
array(
'key' => 'book_type',
'value' => 'Fiction',
'compare' => 'LIKE',
)
),
);
$query = new WP_Query($args);
$fiction = $query->found_posts;
Related Posts:
- Post loop count is not in order
- Custom post type showing same Post on all Pages
- Why would social icon badges disappear after adding a custom post type?
- Sort a custom post with ACF: Date Picker & Display Featured!
- ACF repeater field usage
- List of users that clicked a ‘Join’ button at single post
- How to inherit field value from parent post into in child / sub post
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- Custom Post Type page sorts differently on different environments
- Postname on unique permalink structure appends “-2” for a custom post type. How can I get this to stop happening?
- set_query_params using custom params defined in functions file?
- Custome fields not displayed
- I am trying to get cutom post cout by month of current taxonmy term
- Create short URL with auto 301 redirect
- ACF for custom post type archive pages: which hook to use?
- How to define the template for custom posts?
- Batch Extract Date from post title and put into ACF custom field
- Query entries from custom post type in an ACF flexible content field
- Why is wp api returning old acf values?
- How to use single.php for creating, reading and editing Custom Posts with ACF
- Distribute Custom Post in different pages
- get custom post type value in header.php [closed]
- how to count the current posts terms
- posttype and custom fields on multisite
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How do I replace the post title with a custom field?
- Advanced custom fields Post Object image field not displaying in custom post type single.php
- Sum and count of custom field values
- Trying to add a class to post links
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- How to export custom post type with ACF to individual file with automation?
- How to count other posts not having specific taxonomy terms?
- WordPress Count posts within a custom post type
- Custom fields not showing in custom post type
- Group by custom field value (start and end times)
- Custom post types, disable fields
- meta query not retrieving posts
- Custom Post Type with Configurable Sidebar via ACF
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis
- ACF Relationship Posts how to show additional content
- wp-includes does not contain a feed template
- Using WP meta query to show custom post types by a start and finish date
- Limit search field to just search a custom post type with custom fields
- Advanced custom field – posted fields from custom post type
- Display custom post counts for author , not default posts
- Excerpt length: get first paragraph
- SQL query – get ids – Advanced Custom Fields / WPeC
- Custom field with Types: get custom field’s value label (of type select)
- How to display author details in a custom post type in the wordpress backend?
- Show posts associated with ACF post object and custom post type
- Show/hide posts and categories based on user meta
- Fetch data from two custom post types and create multidimensional array for output to html table
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- How can i show ACF in post excerpts
- ACF – Retrieve custom taxonomy from a relationship field
- How to set a ‘page’ as parent of a custom post type?
- Custom front-end form for adding post – Category problem
- Set up a WP Cron scheduled event to update calculated ACF field
- Query filter by value in meta_value array
- Show Post Revisions on front-end
- count & sum the value of custom field of the author post in dynamic posts
- How to show Custom Post Type – Case Study using Shortcode & ACF
- Add custom post related by custom field to custom post
- Create if else for post types in WP_Query ‘post__in’ values
- Create loop from selected terms in ACF taxonomy field
- Sort custom posts by date and then by taxonomy
- Grouping custom wordpress post types by acf value
- Set Post Private if no linked Post Objects (ACF)
- Show in an entry a Custom Post Type associated to a post
- Orderby custom fields is not working
- Custom post ID & display information related to this ID
- Using ACF values in nested WP queries for CPT with date values in the past
- Create/populate Custom Posts ACF fields from external JSON file
- Expire post to draft by date-picker custom field
- display post count in archive page that have relation with another taxonomy term
- WordPress URL rewrites using Advanced Custom Field
- Custom Post Type and Structure Question
- Display a Custom Post Type with Advanced Custom Fields on Homepage
- CPT email notification including only new value custom fields
- Filter result of Custom Post Type using meta_query with ACF
- How to display posts with plugin (advanced custom fields) field groups?
- WordPress – display relationship between blog posts and custom posts
- Display category filters for custom post type when category is shared by multiple post types
- How do I find the count of the current post?
- Same custom post type with different ACF
- Query posts by current ACF meta key value on single page as related posts
- Custom sorting in post columns by ACF Pro Select Field
- Load info from customposttype into template page
- Show custom post type event if current day using ACF
- Display Custom Field or Custom Taxonomy in front page /post/product
- Why do my custom post types stop displaying over time?
- WP_Query not using custom taxonomy categories on custom post type
- How would i insert a value of custom field from Advaced Custom Field into shortcode generated by Gravity Forms [closed]
- Issue to display Permalink (ACF Relationships in Custom Post Type )
- Auto generate excerpt from ACF field on a CPT that does not support excerpt or content
- How to access repeater field of a custom field?
- Filter posts by their related field’s custom field
- get_queried_object not work in taxonomy page
- If ACF Post Object post has custom taxonomy term…