What I would suggest is to create a custom WP_Query
. What you would do is something like this (modified from ACF documentation):
<?php
$posts = get_posts( array(
'meta_query' => array(
array(
'key' => 'in_row_view',
'value' => '1',
)
)
) );
if( $posts ) {
foreach( $posts as $post ) {
// Do something.
}
}
So, in your code, you will not use the base while(have_posts())
loop but a loop iterating the post (the foreach
in my example).
Related Posts:
- Batch Extract Date from post title and put into ACF custom field
- WordPress – display relationship between blog posts and custom posts
- Adding specific custom fields (images) to post excerpt
- Styling first post using Advanced Custom Fields
- WP_Query Pagination on single-custom.php
- Getting custom taxonomy from custom post type
- Filter next_post_link() and previous_post_link() by meta_key?
- Make featured image required
- previous_post_link() and next_post_link() with a custom post type?
- Setting a custom sub-path for blog without using pages?
- Automatically fill custom field value on post publish/update
- Make permalinks based on an ACF-field
- Custom Posts on Different Pages
- taxonomy list display custom post count
- List events by month
- Use Custom Post Type as Custom Field
- Custom Post Type by user
- How to create posts (not post template) to be displayed on projects page?
- same archive template for different custom post
- Pull image from ACF field in a Custom Post Type
- 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?
- How can I show a custom post type for users in the authors.php file?
- Auto-generated posts not showing in backend (but being counted!)
- Need help targeting a custom post type with conditional tags
- Show the same Article Available in Other Categories
- Problem with WordPress query on page using custom fields
- Show custom post type filtered by category
- Display random posts, but omit the post it is on?
- Get latest 3 posts from multiple CPT in one query
- Meta query for custom post type ignored in main query
- Hiding posts by other users and non-logged in
- Custom Taxonomy terms aren’t getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?
- Get related posts of child term of custom post type
- Troubles with acf/save_post and WP_Query
- Query custom post type with ACF Date
- CPT archive admin menu label
- Order Custom Post Type by Custom Field Value
- How can I show 1 featured post in a styled element, and the next few below differently styled
- Adavnced custom fields relationship query plus query inside
- wp_insert_post wrong post type [closed]
- Custom post type showing same Post on all Pages
- Can I change my post type to anything and my site still work?
- display posts of custom post type with custom taxonomy
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- Post Query not working
- How to filter url on post submission?
- meta query not retrieving posts
- creating files for displaying different custom post type posts with paging
- is it possible in a custom post, create custom fields as well whitin?
- custom taxonomy listing returns no posts
- How to controll the Posts post type and general wondering about WP data structure
- Display author box on just certain category posts?
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Am I mixing up the concept of posts pages and categories?
- If/Else child list for Custom Post Type single template within loop?
- redirect after submiting post for review
- How to achieve a multi-taxomony layout with posts?
- Custom front-end form for adding post – Category problem
- i need to have a tab with gategory post
- Custom Post type to Woocommerce Product type
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- Enforcing a rigid reusable template structure for similar posts?
- Auto delete pages/posts without views
- Post template not applying on theme (potentially rendering as Page template)
- Query posts by current ACF meta key value on single page as related posts
- Show custom post status when logged out
- Permalink URL connection between two custom types
- $_POST from a Meta Box
- Show specific posts with WP_Query using ACF Post object
- User Archive page for Custom Post Type – Pagination Issue
- Autofill advanced custom field with user data
- Advanced search form with multiple custom fields
- Custom post type option page template
- Custom post Query and WordPress Post Query Clash
- How to get a custom post type archive paged when using a custom field for post sorting?
- Multiple Custom Post Type with different Taxonomies
- Links Image in “Catalog” Page to Posts
- Filter By Term Not Working – Custom Post Type
- how to display notifications in the wordpress menu when a new post is published
- Editor role isn’t seeing specific post type posts with only post_type parameter
- How can draft post after 1 year
- Custom Post Types and Posts are mixed
- How to create content automatically when a post is published?
- using ACF datepicker to filter posts on a page
- query_post causes the posts to be loaded twice on load more posts
- Hook only specific post type
- Custom Post Type permalink not working on new posts
- Retrieving IDs of child pages which are in a different post type
- How to query the content of a specific custom post type?
- Turn post into simple slideshow
- post in a lightbox?
- Query multiple post of which one by taxonomy
- Cannot exclude particular post from loop of custom post type
- the_content() stop images being pulled through
- ACF – Query relationship without ID
- Different layouts for different post types in wordpress?
- How to create a job post by email parsing? [closed]
- How to automate the creation of advanced layout article/post
- Display code if title of the custom post matches title of other post