There is no output for this sample code because the IF statement you used will never return true, since the string ‘post_type’ will never be equal to any other string but ‘post_type’.
Use get_post_type():
if ( get_post_type() == 'eventtype1' ) {
To order by a date custom field, you will need to use the same field id for all the post types if you wish to query all of them together.
$args = array(
'post_type' => array( 'eventtype1', 'eventtype2', 'eventtype3', 'eventtype4' ),
'posts_per_page' => -1,
'meta_key' => 'start_date',
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
http://www.advancedcustomfields.com/resources/how-to/orde-posts-by-custom-fields/
Related Posts:
- Filtering a WP_Query meta_query by numeric values isn’t working
- Query by 2 values of a repeater ACF field
- Query current and future events, ordered by begin date
- Display posts if a custom field value is equal to another custom field value
- Remove duplicated values from a loop
- Custom Post Types not showing, custom WP_Query
- Custom Post type and Custom Field WP_Query
- WP_Query order by custom field, then randomly order some of results
- Troubles with acf/save_post and WP_Query
- Query custom post type with ACF Date
- Stuck in Order by more then one
- Order Custom Post Type by Custom Field Value
- Query Custom Post Type Taxonomy term with multiple parameters
- Query based on custom fields start and end date
- Why is my WP Query not returning first result’s post meta?
- Group by custom field value (start and end times)
- Using WP meta query to show custom post types by a start and finish date
- Create if else for post types in WP_Query ‘post__in’ values
- Sort custom posts by date and then by taxonomy
- Using ACF values in nested WP queries for CPT with date values in the past
- Filter posts by their related field’s custom field
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- Show specific posts with WP_Query using ACF Post object
- Linking posts together with Advanced Custom Fields “both ways”
- Custom Field as Custom Post type element class
- How to query posts by meta keys AND under specific category?
- Custom Post-type not returning the right child_of
- Display ACF object field data using Elementor Custom Query
- WordPress WP_Query Sort by 2 dates – custom fields
- WordPress duplicating posts from single loop
- Custom fields disappearing when a custom post type is assigned
- Filter by custom field in custom post type on admin page
- AJAX search on post pages by custom post type
- Select All in Parent Category, Group by Child Category?
- get_query_var() not working in pre_get_posts
- WP_Query ignores post_type in category view
- Populate a ACF Select Dropdown from Custom Post Type
- “pagination” (but not really) and queries using custom posts types
- Pre_get_posts Gives 404 on Custom Post Type
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- Count custom post types with a specific meta value
- Query for posts from any post type but only add instock products
- Query not returning CPT posts
- Custom Taxonomy and tax_query Issue?
- Unable to display multiple post types in same query (WPML WP_Query)
- WP_Query with custom post_type and cat retrieving unwanted posts with the custom posts
- Query to get the author who having maximum number of post (custom post type)
- Pagination not working
- How to use custom post type APIs, but use a different db table
- Display all Posts and only certain Custom Post Types with meta fields
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Select menu should display categories and the item’s depth
- Custom Post Order for a Custom Post Type
- Show Post Count of a Category
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Lists Posts from CPT that match the Title of the Page
- Filtering by Post Meta Custom Fields – Performance
- WP Query—Relationship between two custom post types and their fields
- Unable to get paginate_links working with a custom query [duplicate]
- ACF simple text field value not showing
- Post Object Filter by Custom Field, not title (ACF)
- Using DISTINCT in wp_query
- Related posts in all categories of current post (custom post types)
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- How to show CPTs in term archive
- shortcode to show custom post types by category
- Query/list all terms and their custom post count
- Genesis filterable portfolio isotope [closed]
- convert custom query to wp_query
- Get custom taxonomies from multiple posts
- Pagination on with query_posts in custom post type template
- Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”
- Custom post ui plugin & WP_Query – Polylang
- How to add a post slug to a url?
- How to use load more custom post type data normal or according to on click category tab In WP
- ACF Field on CPT Slug
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Custom Post Type + ACF and performance [closed]
- Meta Query Not Returning Output Despite Having Matching Values
- Polylang non-default language ignores tags in WP_Query
- Problem: wp_query outputs all images on site
- wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query
- The loop seems stuck to a single (now deleted) post
- Displaying custom field according to date
- Query custom posts from custom taxonomy
- Excerpt length: get first paragraph
- Random item on Custom Query working Local but not on live
- Filtering posts based on three taxonomies
- Best way to have one product in both rental and sale parent category
- How do I display specific custom posts, and how do I edit a post’s singular page?
- wp_query return nothing
- Get archive of posts separated by taxonomies and subtaxonomies
- WP Query WordPress Post Type with the same Taxonomy name
- direct custom post query interferes with other queries on page
- How to Get The Taxonomy Term in Custom Post Type Loop Inside a Wp Query
- display custom post type from register taxonomy
- Wp-theme Development
- Elementor Custom Query to get Posts by ACF (Post Object Field
- Made a Custom Post Type using ACF. Via the dashboard I cannot see the view button to see the post