Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How to order custom posts by one of the custom fields value, ‘date’?

the best way

If you input the gig time as a unix timestamp (using strtotime()), then you can use WP_Query‘s meta_value_num in the orderby element to set the order. You can also use WP_Query‘s meta_query to only get posts that have a date that occur in the future.

the other way

If you can’t do this for some reason or another (probably that your date is already set), if you get all the gigs, you can reorder the array of posts based on a strtotime() of your meta value. This will be a heavier implementation performance wise, so go with the other one if possible.

Related Posts:

  1. Query all posts where a meta key does not exist
  2. what is the correct way to compare dates in a WP query_posts meta_query
  3. Get post with multiple meta keys and value
  4. Admin Area Custom Type Search By Meta Fields Without Title & Content
  5. Echo all meta keys of a custom-post TYPE
  6. How can I filter posts by post_parent in the admin?
  7. Post metadata deletes itself
  8. Detect meta value changes when post is updated (post_updated)
  9. Custom Post Type: Set post_title equal to a custom post type field
  10. I can’t set meta_key in my custom post type query
  11. Compare 3 custom fields and sort by oldest
  12. How can I include meta box content when searching?
  13. update a post meta from a single table cell TablePress
  14. Custom Meta Boxes – Nonce Issue – Move to trash issue
  15. Automatically adding meta data to posts or multiple query help
  16. Trigger “unsaved changes” dialog for custom post meta changes
  17. Conditionally Query Custom Post Types by Post Meta for Blog Home Page?
  18. Displaying custom posts only if custom meta box’s date is not expired
  19. Displaying Metabox value (custom post type taxonomy)
  20. How do I sort a custom post type admin column using two meta keys?
  21. How can I display my custom metaboxes on a custom post template?
  22. get_post_meta is returning image id
  23. Custom Post Type, Saving Multiple Checkboxes
  24. Create a random unique 6 digit number as custom field for custom post type
  25. Export entries and multiple custom field meta to .csv?
  26. how to interconnect custom post types?
  27. Metadata for a taxonomy – is there any WordPress way of doing this?
  28. orderby in custom WP Query does not work
  29. Update CPT post meta with update_post_meta and cron job
  30. Insert post metadata for all posts in CPT at once if metadata no existent
  31. Display custom post type from dynamic custom field
  32. Populate dropdown from one custom post type inside another custom post type
  33. Notice: Undefined index: error and understanding wordpress
  34. Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
  35. Get posts between custom dates
  36. Deleting Custom Posts & Meta Data on Uninstall
  37. How do I create an archive page as a including metadata?
  38. Two Custom Post Types Many to Many Relationship
  39. how can I register a post_meta field in an existing CPT and then call it again with get_post_custom()?
  40. post meta parameter in post custom-post-type endpoint with restapi
  41. Update postmeta Parent when post_status child change
  42. Update database from Quick Edit according to Checkbox state of Custom Post Type
  43. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  44. Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
  45. Dynamic Custom Fields
  46. Show Custom Post Type meta boxes only on Page Edit
  47. Custom filter function not working with Custom post type
  48. Custom fields for custom post type
  49. Is there a way to exclude posts based on meta_values?
  50. Submitting Custom Post Types with custom fields from Front-end form
  51. create custom meta box with default value
  52. How to Echo Metadata Value in Currency Format
  53. Filter posts by tax (dropdown) and meta value
  54. Publish and save specific postmeta to a filtered post_type
  55. WP API Response does not show my registered metadata
  56. Batch Extract Date from post title and put into ACF custom field
  57. How to handle this specific case of custom post type?
  58. Save CTP post meta different values each day without overwriting previous values
  59. get_post_meta returns NULL in front-end, but correct result in back-end
  60. Problem with adding custom post type meta to header by plugin
  61. Meta box data is saved but NOT displayed in the meta box text field. Why?
  62. Echo custom post meta from options array
  63. Value of post meta dropdown is not showing in WordPress
  64. Sanitaizing Select Optin For Custom Post Type Metabox in WP
  65. HM CMB: Post Select Field for CPT ID
  66. Getting WordPress to store 0 values for custom post type meta
  67. Problem Saving Custom Post Type Meta Values
  68. Custom fields for post or terms which don’t update on post update
  69. Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
  70. How to use multiple Meta Field from CPT as Post permalink
  71. Show posts from WP Custom Post Type selected from a field in a metabox
  72. Creating an archive page or simple template to list all values of a custom field of specific post type listing
  73. Peepso: Add extra data field (custom post meta) to postbox
  74. Change picture attachment meta of all occurrences of a picture
  75. Unknown Post Meta Records
  76. Get Previous Post based on Custom Field Name, for Custom Post Type
  77. Saving custom post types post_meta over REST-API fails
  78. add action save post type and update post meta woocommerce
  79. get_post_meta not working with variable as a post_id for dynamically get the postid
  80. How to get post detail based on URL of the post
  81. Linking posts together with Advanced Custom Fields “both ways”
  82. Add more custom fields when creating a new custom post type
  83. Stripe multiple transactions
  84. Edit is changing my custom’s post type parent id
  85. Disable Facebook Comments Automatically On CPT
  86. How to add post reference field to a plugin?
  87. Problem with ‘save_post’ hook not running
  88. WordPress custom post type
  89. Edit post meta direct from post.php?
  90. Howto: use existing post_meta as options for a different metabox (checkboxes or list)
  91. Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
  92. Change the contents of a dropdown through the admin panel?
  93. Top 30 Songs using Custom Post Type
  94. Advice Needed for Post Meta Database Efficiency
  95. fetch meta fields inside a widget
  96. Custom post type – update_meta not working
  97. Use a Variable in update_post_meta as the $meta_key
  98. Update an existing post in a custom post type
  99. Post Meta for Custom Post Types
  100. getEntityRecords/useEntityRecords: How to use CPT metadata?
Categories custom-post-types Tags custom-post-types, post-meta
Stripping and/or altering the content of a custom field (video URL)
Export WordPress from one domain to another domain

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress