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

Which is best in the following scenario : post_meta vs custom table vs parent/child posts

As you will probably want to eventually do some reporting on the data, e.g. print a temperature average from this month last year in area X, I’d opt for custom tables from the beginning. I’m saying tables, because I don’t see a reason why you wouldn’t put the locations into a custom table as well. If you ever want to do something like calculate distances (and you have the lat & long for your locations stored), this will make your SQL much cleaner and easier to write.

Post meta data isn’t normalized, and will be painful to work with if you have more complex scenarios. It also doesn’t contain useful indexes, as it has no data type associated. This might not be a problem initially, though, as your data set is still quite small.

The only thing FOR meta fields in this scenario is that you could use WP_Query directly and without a lot of hassle. But I’m rather confident that you could add some functionality to wp_query via filters – and you’d have to use those fore advanced stuff anyhow in order to manipulate the auto generated SQL.

That said, it also depends on how quick you (and any other people that might work on it with you) are when developing with a special table vs some pure WP based solution. You could always start with 3, and if the project takes off, you invest a bit more time to make it nice and clean and go for 2. The data conversion shouldn’t be that big of a problem.

Related Posts:

  1. So much data in postmeta
  2. What is the advantage of the wp_options design pattern?
  3. importing data from non-wordpress mysql db
  4. Ordering posts by anniversary using only day and month
  5. Displaying posts with only upcoming dates according their custom field date value
  6. How to add a new meta key and assign timestamp to posts
  7. How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
  8. Ordering posts by custom field named “date” in backend
  9. Unique meta_key with array value vs repeated meta_key with single values
  10. Avoiding ACF get_field and returning to core WordPress function
  11. change order of images attached to post
  12. Diamond question mark in text after migrating content
  13. How to improve my non-unique metadata MySQL entries?
  14. WP Query Args – search by meta_key or title
  15. SQL query based on two different custom field values
  16. Using meta query (‘meta_query’) with a search query (‘s’)
  17. Can I exclude a post by meta key using pre_get_posts function?
  18. Custom post meta field effect on the performance on the post
  19. How to get custom post meta using REST API
  20. Difference between meta keys with _ and without _ [duplicate]
  21. Orderby meta_value only returns posts that have existing meta_key
  22. What is the index [0] for on post meta fields?
  23. What is “meta_input” parameter in wp_insert_post() used for?
  24. How to enable revisions for post meta data?
  25. The “_encloseme” Meta-Key Conundrum
  26. ORDER BY custom field value
  27. Best way to programmatically remove a category/term from a post
  28. Using get_post_meta with new_to_publish
  29. Can I query custom meta data through WP_Query
  30. Add custom fields to search
  31. SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
  32. Matching Serialized Arrays with meta_query
  33. Custom field metabox not showing in back-end
  34. Meta Query with AND & OR?
  35. Can I count the number of users matching a value in a multiple value key?
  36. Getting attachments by meta value
  37. When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
  38. How to hide meta box values from custom fields list?
  39. Auto sort the wp-admin post list by a meta key
  40. get_post_meta() unserialize issue – returns boolean(false)
  41. Remove old custom field after import
  42. Storing meta fields multiple times OR once with multi dimensional array?
  43. Allow user to create instances of custom field
  44. display specific custom fields
  45. How Can I save multiple records in same meta key?
  46. Is there a hook / action that is triggered when adding or removing a post thumbnail?
  47. Edit Custom Database Tables in WordPress
  48. Meta keywords and descriptions plugin for manually editing meta for each page/post
  49. Meta query interfering with orderby relevance
  50. passing argument to get_template_part() or a better way to code
  51. Is it possible to store arrays in a custom field?
  52. Get updated meta data after save_post hook
  53. Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
  54. Save HTML formatted data to post meta using add_post_meta()
  55. Trying to perform complex custom field query with order by set to field value
  56. How to delete custom field “suggestions” from dropdown list
  57. What is an efficient way to query based on post_meta?
  58. Is there a way to do multiple ordering on a multiple meta_query?
  59. Create meta boxes that don’t show in custom fields
  60. Transients vs CRON +Custom Fields: Caching Data Per Post
  61. Unable to save datetime custom meta field using update_post_meta() function
  62. Up/Down voting system for WordPress
  63. post meta data clearing on autosave
  64. WordPress Search Custom Meta Field Only
  65. Create custom field on post draft or publish?
  66. Display info from custom fields in all images’ HTML
  67. Compare meta_query decimals not working right
  68. Register new user and add custom data row value for it
  69. WordPress altering my custom query, How to fix it?
  70. Calling Specific Pages with wp query Part II
  71. Loop through two different sets of custom fields
  72. get_post_meta fields don’t show up on posts page
  73. Update meta values with AJAX
  74. How to break meta values into different items and avoid duplicates?
  75. copy attachments to another post type and change attachment url
  76. Cannot edit post meta fields with rest API
  77. ajax delete value from custom field array
  78. Save attachment custom fields on front end
  79. Slow meta query with multi meta keys
  80. After moving my site from a dev subdomain, to root, all my custom meta data is gone
  81. Front-end update_post_meta with ajax
  82. How to use pagination with get_post_meta
  83. Copying Custom Meta Values from existing post to a duplicate post
  84. Using OR in WP_Query negates the “NOT EXISTS” compare
  85. Add a post meta key and value only if it does not exist on the post
  86. How can I query on the year part of a complete date in a custom field?
  87. Move value of one custom field to another
  88. Order posts according to user defined order for meta values?
  89. How can I combine meta_query queries?
  90. Advice needed for importing custom field data and database structure
  91. Sanitizing `wp_editor();` Values for Database, Edit, and Display
  92. Exporting Data from WordPress into a flat table
  93. Custom fields to save multiple values
  94. Custom fields: In what order are they saved into the DB?
  95. Function to change meta value in database for each post
  96. Get a post_id where meta_value equals something in a serialized meta_value field
  97. Get aggregate list of all custom fields for entire blog
  98. Difference between ‘LIKE’ and ‘IN’ in meta queries
  99. Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
  100. Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
Categories custom-field Tags custom-field, database, meta-query, post-meta
Best way to notify WordPress plugin users of new release candidates for beta testing?
Redirect “Sorry, you are not allowed to access this page.” to Home

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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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