The correct array key to use is meta_key
, not key. You can only use key
as part of a meta_query
subarray, where the ‘meta’ part is implied.
This is all described in the codex.
Try
<?php $activities = new WP_Query( array(
'post_type' => 'timeline',
'posts_per_page' => -1,
'meta_key' => 'activity-date',
'orderby' => 'meta_value_num',
'order' => 'ASC'
)); ?>
Related Posts:
- How to sort CPT by custom meta value (date), and return posts month by month
- List upcoming events, ordered by date in a custom field
- Display custom post types with custom date field value (before today) & order by custom date field
- Rewrite and custom post type: order by custom field not working
- Order Custom Post Type by Custom Field Value
- Meta Query posts not showing on ending date of custom field
- Add a custom meta box for client to order CPT posts how they want
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Sort custom post type by most current date picker
- How to display a WordPress Custom Field only on a specific day of the week?
- Filtered by a custom field, ordered by another
- Problem with date comparison for custom fields
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- Orderby if between two meta fields
- What’s the most efficient way to get two queries based on an if statement?
- Show first posts with custom field not empty and order all by title
- Pre_get_posts comparison with custom field doesn’t work
- Get month and day from a Date Picker custom field
- How to get past and upcoming post by defining date in custom field?
- Order Custom Posts by Several Fields
- 404 on Pages for Custom Post Type & Query_Posts
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Order Wp Query by earliest of 3 dates meta query
- How to display *block number* instead *date value* on WordPress posts?
- Many CPT is conflicting of the custom date
- Woocommerce custom field search in custom post type [closed]
- Add custom field in comments form
- How to order and group custom post type posts by year and month
- Custom Fields for Custom Post [closed]
- Filter custom post types by a field value
- Displaying All Posts of a Custom Post Type in WordPress Multisite Backend
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Custom REST endpoints for a custom post type with custom fields
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- Hierarchy and access control for Custom Post Types (CPT)
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- First custom field value (out of several) displayed twice after query
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Get the taxonomy of a post hierarchically
- Cannot save CPT meta box
- Change sort order when using ‘orderby’ => ‘type’
- Cross reference custom post types
- Adding Page Templates to post but it ignored it
- Display Woocommerce Orders for specific author [closed]
- Include related custom fields from one post type in another post type’s JSON feed
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- frontend image post uploader
- Use the same date-based permalink structure for all post types
- Is there any way to add a “custom field” to the CPT archive page?
- Ordering custom post type by multiple custom fields
- How to Output which matched meta_keys were found from custom_type_posts?
- Multiple Frontend Filters Using Advanced Custom Fields
- Custom Post Fields at the beginning of a Custom Permalink
- Integrate Custom Post Type Events into Calendar
- Possible to filter custom post type with multiple meta data?
- Hierarchical custom fields
- How to get a custom field value of a custom post?
- How to order posts of a custom post type by date DESC in dashboard Admin?
- Fields for different parts of a page
- Is it possible to activate customfield ‘text description’ upon activating the customfield ‘checkbox’?
- Order post by date with ACF
- Facebook social publisher and custom post type fields [closed]
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- Displaying and searching Custom Posts
- Importing Data from a Non-WordPress database, into WP
- custom comments form for custom post type
- Searching Custom Fields
- Show fields based on taxonomy selection in editor
- Manage Columns : order by post_parent’s title
- filter search custom field query
- Permalinks: custom structure for taxonomy – tags?
- Order by custom field meta_key date and then by custom file meta_key number
- How to let users choose where to search for posts?
- don’t publish custom post type post if a meta data field isn’t valid
- WebP Fallback for Inline Background Image in Style Attribute
- Query based on custom fields start and end date
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Custom fields for custom post type
- How can meta boxes be added to “unknown” custom posts?
- Custom “radio button meta box” not saving correctly
- It’s possible to hide body copy box for a custom post type?
- Can we create a custom post template for a specific page template
- Warning: Invalid argument supplied for foreach() [closed]
- Settings API – save multiple tabs at once
- Add additional field to custom post_type
- How to Get the title of a custom field?
- Custom Post Meta from custom metaboxes is randomly being deleted
- Ordering posts by custom field named “date” in backend
- Check if post with same meta value exists
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- Archive not sorting correctly
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Multiple single templates?
- Ascending Order is not Working in Custom Post Type Listining
- Custom Field values not Showing in Edit Page of Custom Post Type
- How can I add a custom field to an existing custom post type?
- Custom posts type for individual pages?