You are missing $locations->the_post()
in your loop:
if ( $locations -> have_posts() ) {
while ( $locations -> have_posts() ) {
$locations->the_post(); // Needed
echo 'yes';
}
}
One of the things this function does is advance $locations
to the next post. Without it $locations->have_posts()
will just repeat infinitely for the first post.
Related Posts:
- Meta Query “IN” doesn’t work with ACF checkbox filter
- List events by month
- Show ACF field from custom taxonomy and display on the single template
- Change message given when deleting post from custom post type
- Link users to a custom post type
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- get_posts of Custom Post Type AND Custom Taxonomy
- WP_Query to select custom post type with Advanced Custom Fields (ACF) date
- How to update post meta on uploaded image from a custom form?
- Displaying custom field according to date
- Create short URL with auto 301 redirect
- meta query not retrieving posts
- Fetch data from two custom post types and create multidimensional array for output to html table
- Custom front-end form for adding post – Category problem
- count & sum the value of custom field of the author post in dynamic posts
- Grouping custom wordpress post types by acf value
- WordPress – display relationship between blog posts and custom posts
- Custom sorting in post columns by ACF Pro Select Field
- Load info from customposttype into template page
- CPT: execute code after load if parameter is set
- ACF Post Content Not Being Searched
- Display related post content and custom field content
- Group/list/sort custom post type posts by date in tabs from acf datepicker field
- Can’t pick up a field created with Advanced Custom Fields
- Custom post tag images not displaying with ACF
- Get month and day from a Date Picker custom field
- using ACF datepicker to filter posts on a page
- Custom Post-type not returning the right child_of
- Getting ACF relationship field information
- How to I add count of custom posts listed in a post as a prefix to its title
- How do I programmatically add items of content to a custom post type?
- How to sort a table of custom posts by column containing custom field
- Ajax filter with custom taxonomies
- Custom post type loops with different page templates
- How can I programmatically save data into custom fields that contain serialized data?
- Row actions not showing? Why?
- Displaying custom post type on front page
- Archive filter disappears on no results?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- WordPress custom post type archive with description
- Weird problem happening with custom taxonmy when creating/updating posts
- Validate custom fields before save using WordPress Rest API
- CPT + CMB2: data not displaying for only first post in loop
- How can I dynamically add a post to a custom post type which uses a custom field?
- custom post type WYSIWG removes paragraphs when displayed
- ACF field key/value to show on taxonomy list
- Using custom field content as expression in IF statement [closed]
- ACF From & To Date Validations
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- search suggest – filter post type
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Make a custom_post translatable
- Order post by date with ACF
- Querying & displaying custom post type into an existent page [closed]
- Loop increase number
- Is This Code Efficient – Or is there a better way?
- Post loop count is not in order
- How to inherit field value from parent post into in child / sub post
- Query custom post types & Taxonomies and list them in a table on a page
- Creating a “glossary” of WordPress posts of a specific post type
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- Nested Custom Taxonomies | Incorrect posts when querying
- How do I get the index for a custom post?
- Commas not displaying in implode
- add custom tags for custom post type in wordpress
- foreach loop inside the loop creating duplicates in output
- Custom Post Type Causes Error: Warning: call_user_func_array()
- Is it a connection or relationship between 2 custom post types?
- Get only parent post in archive post
- update custom taxonomy custom fields
- Filter taxonomy by CPT
- Sort custom post column by generated value?
- Show custom post type event if current day using ACF
- Filter posts by their related field’s custom field
- If ACF Post Object post has custom taxonomy term…
- Custom post type order by post_title
- Changing default admin column sorting to an ACF Date Picker field
- Tell wordpress to show a single page instead of an archive page
- Get meta values from parent post and save in child post
- Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks
- PHP Notice: Unidentified index
- save_post affect creation and deletion
- Duplicate posts in my custom loop
- Include images from pages in wp search.php results in default wp search
- get_post_meta for Custom Post Type ( CPT )
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Meta box not saving
- How to query posts by meta keys AND under specific category?
- Custom Search not working
- 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
- Register a title automatically with a relationship field
- WordPress Set A Static Page/Template For All Sub-Pages
- Add HTML before a specific div?
- How to hide home title on pages and posts?
- Is there any way of not using my_init_method in the following code (that creates a custom post type)?
- Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT
- Two custom post type relations