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

Migrating meta_key and meta_value from old theme to new one

You’d have to look more closely at how the old theme displays the postmeta. At this point, you have a few options:

  • Create a child theme for your new theme, and in its PHP file to display single posts, set the child theme up to display the postmeta just like your old theme did. (You will also have to set up postmeta boxes so that new posts can also contain this postmeta.) That way, if you ever want to switch back to your old theme, you won’t have to change data.

  • Move the data into the posts themselves, as you’ve asked. This may be the better option since it should work with any theme, as opposed to preserving the postmeta. The trick will be to figure out how exactly your old theme was displaying the data, and part of this depends on whether you’re using the Block Editor or the Classic Editor (or a page builder).

For the second option you’ll need to do something like:

Look in the old theme and find how it was displaying the postmeta. You could look at the code itself (likely in single.php)

<?php
if(get_post_meta($post->ID, 'tie_video_url', true)) {
    // The code you're looking for: how the URL gets output
}
?>

or you could look at the front end to see what the end HTML looks like. That’ll be the key to proceeding to the next step.

Once you know what the HTML needs to look like, I’m guessing you’ll need to use PHP because you won’t just be adding the URL to your post content, you’ll need the full HTML. However, if the HTML is simple, your MySQL query could look something like this. (Keep in mind you’ll need to use your own database’s prefix, which might not be “wp_”.)

UPDATE wp_posts INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id SET post_content = CONCAT(wp_postmeta.meta_value, wp_posts.post_content) WHERE wp_postmeta.meta_key = 'tie_video_url');

This simplified query would just take the postmeta value for every post that has the “tie_video_url” meta_key (presumably, the value is the URL) and put it at the beginning of each post’s content. Since an URL isn’t going to transform into a full embed, again, you’ll likely need to work out what HTML needs to wrap around it and use a PHP approach.

Related Posts:

  1. Meta query interfering with orderby relevance
  2. Delete all post meta except featured image
  3. Delete all post meta except featured image Using SQL
  4. Why WordPress choose data serialization over json_encode?
  5. Dealing with Many Meta Values, 30+
  6. What is the most secure way to store post meta data in WP?
  7. How to delete outdated, wrongly sized images in _wp_attachment_metadata?
  8. Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
  9. What is an efficient way to query based on post_meta?
  10. How to solve slow WordPress site caused by attachment_metadata
  11. Exporting Data from WordPress into a flat table
  12. Set Display Name to first and last name (phpmyadmin SQL Query)
  13. Emojis getting converted to “?”
  14. Which is best in the following scenario : post_meta vs custom table vs parent/child posts
  15. How to replace values in WordPress DB using phpMyAdmin
  16. Is it possible to store visitors IPs in wp_postmeta table?
  17. Multiple postmeta with same name for one post in wp_postmeta table
  18. Accidentally deleted active_plugins portion of the wp_options DB table
  19. One post carries 30 postmeta values, is this too much?
  20. delete post meta from db, even if does not exist?
  21. WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
  22. Storing data for a wordpress plugin
  23. Where does the actual data stored by add_post_meta
  24. Structure of postmeta meta_value for woocommerce product download
  25. WordPress database import: Row size too large
  26. Routine to convert custom post meta from old to new value
  27. WordPress Database Huge wp_usermeta Table
  28. Saving zero as meta value
  29. Uknown meta entries in wp_postmeta
  30. Connection refused on locahost after importing database?
  31. Does post_meta data need to be unserialzed?
  32. Changing root password in PHPMyAdmin for WordPress Database when going live
  33. Can’t update WordFence Options, clear data manually
  34. Post Views / Hit Counter Problem?
  35. How to migrate a database from a server to another
  36. Link image with data from the wpdb
  37. SELECT SQL_CALC_FOUND_ROWS with wordpress search
  38. Files on Localhost, Database on Server
  39. Backing up WordPress database and files
  40. Custom Post Type not showing anything added by code anymore?
  41. wp_option table error while importing
  42. Installing local to live WP into subdirectory
  43. Delete user with only subscriber role
  44. Can’t log into wordpress site – I have made a new user and still cant access
  45. Compare User meta_value with Product meta_value
  46. Is there any way to monitor a MySQL db and check what has changed?
  47. How to save EXIF metadata in WordPress database?
  48. _wp_attachment_metadata is not being added to database when PDF files uploaded
  49. Best Practice? – Saving multiple Values as Serialized Data / Saving each Value per Row / Dedicated Table
  50. DB prefix not updating
  51. I wanted to Know that how can I give ingore to 0000-00-00 in my config file
  52. I imported an restore an database and It shows #1067 – Invalid default value for ‘user_registered’
  53. I need to find posts that contain YouTube links without http:// or https:// prefix and add http:// to all of them
  54. “BS_” rows in postmeta table
  55. Is there any defects for using same database prefix in WordPress for multiple sites?
  56. What is recommended data type and encryption type for password in a database
  57. syntax error for changing user role from database
  58. Duplicate database to roll back theme & content changes
  59. WP website showing blank page after moving from subdomain to main domain
  60. Database structure for thousands of posts
  61. How to retrieve user data based on role using SQL?
  62. How much post meta data is too much?
  63. WordPress character set issue
  64. Missing latest posts and options after DB migration via phpMyAdmin
  65. Check if a database is well installed
  66. Changed meta_key value in structures, now dashboard shows zero users
  67. How do i get value from wp_postmeta?
  68. Options table – where does my values go?
  69. Database question while Migrating from one domain to another on same WebHost [Bluehost]
  70. Recommended Post Structure for DB Storage
  71. SQL query : Select a thumbnail for a media
  72. WP_Query by meta key not returning any posts
  73. Deleting WordPress posts and media files based on author via MYSQL database
  74. Database table prefix different between wp-config.php and in database
  75. Custom form that store input in database
  76. Issue with wp_insert_post and post_content field error Could not update post in the database
  77. wp_posts – guid update
  78. Where is custom template file chosen for a post stored in the DB?
  79. Safe way to find last inserted id in a table?
  80. WordPress DATABASE Update Manually?
  81. Which is more efficient? Using usermeta, or creating a new MySQL table?
  82. How to replicate a user plugin made table value, to this user’s custom meta table value?
  83. How and where is wordpress adding mySQL content to database?
  84. How to delete a particular row in a database table
  85. delete duplicate meta_value with same post_id
  86. change the year on all of my custom post types?
  87. custom tables in wordpress Database? (can i just create them with sql?)
  88. Accidently changed the GUID
  89. Use WP_query to match post types based on custom field values
  90. why not selecting multiple rows of same standard_id using SQL query from database?
  91. Updating database with CSV file and Cron job
  92. Improving wpdb queries with large data
  93. Why is wordpress trying to re-install itself?
  94. How to Determine a Post’s Last Edited Date?
  95. Inserting into data into external DB using WPDB
  96. Error at time of WordPress Installation
  97. WordPress dbdelta a semicolon
  98. single.php not pulling in any data from database
  99. How do I use update_option to give me a new option name each time a form is submitted? [duplicate]
  100. WordPress Theme Customize doesn’t save changes
Categories Database Tags database, meta-query, phpmyadmin, post-meta
admin_notices is not working inside function
I have a random letter appearing before my content. Where to start looking for the cause?

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