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
- How do you get the count of posts in an archive page?
- Mixing regular and custom post types (with meta_query) on home page
- $wp_query->queried_object->ID throws warning: Undefined property
- how to filter by last name for custom post
- Use WP_Query object inside a function
- WP_Query search custom posts meta date fields
- Get posts with tag all post types
- How to get_queried_object on multiple objects?
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- query order by date on custom type: wrong order
- Change message given when deleting post from custom post type
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Calculating Bayesian average for custom post type
- Help with CPT template pagination
- Query Custom Post Types by date (custom field) range
- Custom query shows custom post types in trash
- Fetch taxonomies by custom post type id array
- How to connect two custom post types with nested loops
- WordPress custom loop filter by meta_key and value with serialize data
- Show one item per category of a custom post type
- the_content() not outputting anything (Advanced Custom Fields)
- Mixing 2 custom post types with posts output in specific pattern
- Why is this query not working? (Standard posts + custom post type)
- First custom field value (out of several) displayed twice after query
- Multiple Frontend Filters Using Advanced Custom Fields
- How to set the seo title tag on a page by page basis?
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- WP_query – Filter by tax_query and meta_query using multiple select
- Create a list of recent Custom Post Types posts
- Empty search input does not return all posts
- Adding Multiple Post Types to Query [duplicate]
- WP Query results showing posts outside of category ID
- tax_query (if the terms are empty)
- How to count other posts not having specific taxonomy terms?
- Running a custom query inside another cpt single and trying to grab a variable
- Get posts by category name
- WP_Meta_Query object with conditionals
- Problem while filtering by ‘category_name’
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Fetch data from two custom post types and create multidimensional array for output to html table
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- Query filter by value in meta_value array
- Expire post to draft by date-picker custom field
- WP_Query get always custom post_type for first
- How would i insert a value of custom field from Advaced Custom Field into shortcode generated by Gravity Forms [closed]
- Auto generate excerpt from ACF field on a CPT that does not support excerpt or content
- Custom post type not pulling CSS
- meta query multiple values for the same key
- Custom post types – meta_query: search lesson which starts sooner
- Wp Query sort order from custom MetaBox
- Custom permalink rewrite rules – how do I fix this?
- Most efficient way of showing children posts?
- Automatically convert standard posts with custom fields to custom post types
- Submit and edit font end custom post type
- How to make a custom search template for custom taxonomy?
- How can I use WP_Query argument ‘Like %..%’?
- Custom post type and custom taxonomies display
- WordPress custom post type
- Custom post type single display is ommited
- Query child posts on parents single.php?
- Custom Post Query Combined with Conditional Tags
- Get all custom_post_type posts + blog posts from one category in a single query
- Customising wordpress search and using $_GET[“s”]
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- WooCommerce – Complete Order when an action occurs
- WordPress Loop trouble with ACF [closed]
- Custom taxonomy meta fields
- WP Query – Can’t get posts with specific taxonomy
- WordPress post objects in one parent post object