You can use the fields
parameter of WP_Query
to get just IDs back, then iterate over them with a foreach
loop:
$args = array(
'post_type' => 'services',
'posts_per_page' => -1,
'fields' => 'ids',
);
$query = new WP_Query( $args );
if( $query->have_posts() ){
foreach( $query->posts as $id ){
the_field( 'the_field', $id );
}
} else {
echo 'There are no services';
}
Related Posts:
- Getting custom taxonomy from custom post type
- Filter next_post_link() and previous_post_link() by meta_key?
- Automatically fill custom field value on post publish/update
- Make permalinks based on an ACF-field
- How to sort a table of custom posts by column containing custom field
- List events by month
- Use Custom Post Type as Custom Field
- Pull image from ACF field in a Custom Post Type
- Archive filter disappears on no results?
- Show ACF field from custom taxonomy and display on the single template
- WordPress custom post type archive with description
- wp_update_post based function works on existing posts, but not new posts
- How to Display ACF Relationship Custom Field as Link to Specific Custom Post?
- Show custom field from custom taxanomy term on custom post type
- How to replace custom post type slug with an ACF value?
- Custom Post type with ACF in REST API, how do I get those values?
- Custom Post Types not showing, custom WP_Query
- Create 3 Level Relations with ACF and WordPress
- How to: Display ACF [fields] on Custom Post Types Utilising WordPress ‘Hooks’? [closed]
- Retrieve value of a category’s custom field
- Problem with WordPress query on page using custom fields
- Custom Taxonomy terms aren’t getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?
- WP_Query to select custom post type with Advanced Custom Fields (ACF) date
- Bulk Update Custom Fields for Custom Post Types
- Cluster CPT posts to users based on ACF value from their profile on dashboard
- ACF Values Don’t Show After Import Unless I Edit/Update Post
- Troubles with acf/save_post and WP_Query
- Query custom post type with ACF Date
- Stuck in Order by more then one
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- CPT archive admin menu label
- Order Custom Post Type by Custom Field Value
- Query Custom Post Type Taxonomy term with multiple parameters
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to group posts and get a mixed posts and groups view?
- Integrate Custom Post Type Events into Calendar
- WebP Fallback for Inline Background Image in Style Attribute
- Adavnced custom fields relationship query plus query inside
- Query based on custom fields start and end date
- Why is my WP Query not returning first result’s post meta?
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- How to get a custom type post data when it has a connection with another custom type post?
- Custom post type showing same Post on all Pages
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- ACF for custom post type archive pages: which hook to use?
- 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
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- 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
- SQL query – get ids – Advanced Custom Fields / WPeC
- How to set a ‘page’ as parent of a custom post type?
- Custom front-end form for adding post – Category problem
- Create/populate Custom Posts ACF fields from external JSON file
- WordPress URL rewrites using Advanced Custom Field
- Custom Post Type and Structure Question
- Query posts by current ACF meta key value on single page as related posts
- Show custom post type event if current day using ACF
- How to access repeater field of a custom field?
- Filter posts by their related field’s custom field
- If ACF Post Object post has custom taxonomy term…
- ACF Pro Accessing fields on a Custom Post Type
- Modify Publish Metabox location on CPT
- Some posts not displaying by taxonomy term
- Changing default admin column sorting to an ACF Date Picker field
- Permalink URL connection between two custom types
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- Show specific posts with WP_Query using ACF Post object
- Autofill advanced custom field with user data
- Advanced search form with multiple custom fields
- Custom post type option page template
- Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks
- How to get a custom post type archive paged when using a custom field for post sorting?
- save_post affect creation and deletion
- Can’t pick up a field created with Advanced Custom Fields
- How to query posts by meta keys AND under specific category?
- using ACF datepicker to filter posts on a page
- how to load custom single.php?
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- Function that get ACF fields value before saving
- If you’re calling a dynamic css inline style does that div have to be in the loop?
- How to query the content of a specific custom post type?
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Copying custom field value in to title
- Custom Post-type not returning the right child_of
- How to show animal lineage/pedigree in WordPress?
- Register a title automatically with a relationship field
- ACF – Query relationship without ID
- ACF Relationship: Group posts by parent category term, then child [closed]
- ACF Field to set Publish Date – Post Duplication upon Update
- Getting ACF relationship field information
- Why custom search engine only searches in post titles of custom posts?
- Filter page ID outside the loop and order
- Post object GUID adding http:/
- Custom Sort Order for Custom Post Type Taxonomy
- Display custom post type attached media file sizes
- WordPress post objects in one parent post object