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?
- Adding ‘menu order’ column to custom post type admin screen
- How to Add Custom Fields to a Custom Post Type?
- Do_Shortcode not working for Embed
- Display custom post type and custom fields within a Bootstrap Carousel
- how to filter by last name for custom post
- Search that will look in custom field, post title and post content
- clients list using wordpress
- Custom Taxonomy Template Post List with Sort Order
- Display Custom Post Type Fields
- Order Posts by Taxonomy and Meta Value
- How to do a custom bookmarks post type?
- How do I add media to a custom post type?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- WordPress query by multiple Custom fields and order by date
- add_meta_box: Datepicker like the one for postdate?
- query order by date on custom type: wrong order
- Taxonomy list. Order by a specific custom post type count
- Custom field losing p tags on display
- Using posts and postmeta table to store custom Address Book Plugin data
- Query current and future events, ordered by begin date
- Frontend posting – everything saves other than checkboxes?
- Saving repeated option values in a custom query
- Query Custom Post Types by date (custom field) range
- handling csv data with a custom post type
- Custom fields in Permalinks?
- query posts and custom post type with meta key
- Dynamically add / duplicate custom meta in custom post types
- Custom Post type and Custom Field WP_Query
- Adding Show Less/More link to Custom Post Meta
- Sorting custom post type columns with external data and without meta values
- How to set order for a custom post type
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- How to use TinyMCE Editor for one of my custom post meta field?
- filter search custom field query
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Custom fields for custom post type
- Custom post type sorting: alphabetical order
- Sorting posts by custom field value in array
- Custome fields not displayed
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How to populate a Gravity Forms Custom Post Field (dropdown type) with custom taxonomy terms? [closed]
- Custom post type name and assigning custom taxonomy
- Custom post types, disable fields
- Post ordering not working with custom field
- Building a Portfolio and need some direction
- Custom PT, Taxonomys and wordpress query
- Using global $post; with custom post types
- CMS – User confusion when creating new page and having to select template and save first to see correct fields
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- Creating a custom page post type just like the original “pages” post type using CPT UI
- How to order taxonomy terms by most recent post?
- Display custom posts, ordered by most commented, without duplicates
- Sort custom post archives by a meta value from a different custom post type?
- Displaying posts inside table having issues
- Ordering Post by Meta Key (Not Working)
- Error when moving custom post type to bin
- Using Orderby and meta_value to order natural/alphanumerical
- Enforce all custom posts have specific custom fields
- Use WP Title instead of custom field to call
- Custom taxonomy template for custom fields loop [closed]
- Add more custom fields when creating a new custom post type
- Custom post order when using OR relation
- Amend posts using wp_insert_post
- Custom Fields as Post Type Options
- Change custom post status to draft before today
- Show Custom Post Type taxonomy term that matches custom field
- Select Menu for Custom post Type does not save
- How to save an integer as taxonomy term?
- Allow authors to create article image
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Allow admin to determine the order of queries?
- Display ACF object field data using Elementor Custom Query
- Sortable admin columns ordering from custom fields isn’t combine com search and Dropdown filter
- How to consume external API from WordPress post editor and display the response data in the custom field?