I’m not fun of helper functions so I would write it like this:
$args=array(
'post_type' => 'post',
'posts_per_page' => '20',
'post_status' => 'publish',
'order'=>'DESC',
'orderby'=>'ID',
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$current_id = $post->ID;
echo the_field('field1', $current_id);
}
wp_reset_postdata();
} else {
// no post
}
Related Posts:
- Is there a better way to pull in custom content without querying posts?
- Page template query with WP_Query
- How to prevent execution of default query, while preserving ability to use WP_Query in template?
- Display List Of Posts Containing a Relationship Field Value [ACF]
- Using OR conditions in meta_query for query_posts argument
- ACF Relationship Field Search Filtering [closed]
- How to stop wordpress to make the default query?
- $wp_query initiation?
- Executing Queries in tag.php
- ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format
- WordPress meta_query and order by custom field
- Which custom query am I in and how can I access its properties & methods?
- Revolution Slider Orderby Two Custom Fields
- Single page theme
- meta_query with array as value
- query posts in functions.php and update a field
- Pass the same object to multiple widgets in a template with one query
- Minimising number of queries on a page when using Advanced Custom Fields
- Query Posts depends on custom field inside repeater field using acf
- ACF Relationship + WP Template Parts
- Minimising Database Queries when using Advanced Custom Fields
- ACF – Get lowest & highest value from field
- If two first numbers exist in wp_meta_query value
- WP_Query meta_query >= date
- Have functions work outside the loop with 404 override
- How To Fix WP Query Returns Results But Shouldn’t?
- ACF Date Based wp_query
- Multiple taxonomy And acf filter group by
- Custom query based on meta key – Reduce three states to two in results?
- Include custom field in Ajax search WordPress
- Show all post for a given category
- What is the random string I am seeing when I use get_query_var?
- Any number in meta key (wp query)
- How do I run through a WordPress loop called from a filter function?
- How can I display a custom field from all posts and order them individually from their parent post
- Is there a way to work with a specific the_field from an already queried post? [closed]
- How to Union two different conditions in one WP_Query
- add_filter(‘query_vars’) not working in custom template
- Excluding pages in WP_query using ACF
- How to do a wp_query with two acf-fields, sorting on one of them
- Using Advanced Custom Field for file upload, how do I load the file url
- Multisite wp_query & switch_to_blog issue
- Stuck in the query loop
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- WP_Query with meta_query dosen’t return results
- wordpress ajax relationship query
- Include post content of linked posts in search
- WP User Query with Custom Fields and Search Results
- ACF accessing a field from the query, but not in post
- filter wp_query result with custom field values
- WordPress Custom Search Form Displaying Unexpected Results
- Is there a way to make this kind of loop shorter and nicer?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Merge 2 custom post type posts and taxonomy terms and sort ascending
- Add ACF field in a query
- Utilising an existing page while using the “s” query parameter
- JSON – Create rest api endpoint for Advanced Custom Fields
- Get posts in taxonomy randomly
- Expecting statement error from php loop using ACF plugin
- Custom query filter by ACF date custom field
- How to generate feed for custom template
- Get a list of ACF Repeater-Fields as array
- WordPress dynamic AJAX query
- Unable to paginate a custom page query
- How to stack name list in non-alphabetical order?
- problem with the loop
- WP Query orderby ACF boolean values and ACF field value
- Optimising WP_Query with ACF Fields
- get_children() Archive Template
- Order WP_Query by meta_key priority when ‘OR’ relation used for multiple meta values
- Multi-layered WP_Query
- In a WP_Query can I force the results’ is_singular() to be set to false?
- Oxygen Repeater Advanced Query
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- Nearby locations using Advanced custom fields, maps?
- WP_Query – display posts by custom field and order by another
- WP_Query for distinct meta values
- Group Product Types
- WPQuery Date and ACF
- Excluding posts from search results page with meta query not working
- Populate select list with meta values from all posts of a Custom Post Type
- Form checkbox value going to dynamic URL
- ACF: How can I publish values of ACF fields in a loop while using wp_query?
- WP Query by variable custom field
- create custom shortcode wp and put php code in
- Query for getting posts with their custom fields data in WordPress
- Why does my output of get_the_ID() change after a wp_query?
- How to get taxonomy image attached to a Post Type WordPress
- How to display a post(by id) along with css in a page?
- How to rearrange posts based on input field values added by WordPress “Advanced Custom Fields”
- WP Query with meta queries
- Custom query showing all acf field values instead of the one searched
- WP_Query, ACF field and array
- Pre get posts sort by meta key returns no results if meta key does not exist
- How to query wordpress with array of meta_values?
- ACF query-pass field value
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- Limit default Search query to post_title
- Query string order by custom field
- Get posts meta_query by repater field