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. Help required with local wordpress setup
  74. #1067 – Invalid default value for ‘post_date’ when trying to create a new column
  75. wp_update_post function exclude specific field
  76. WordPress Admin login problems- PLEASE HELP [closed]
  77. Deleting WordPress posts and media files based on author via MYSQL database
  78. Database table prefix different between wp-config.php and in database
  79. Showing Error(TAble already exist)
  80. Which is less DB intensive in the loop: custom taxonomies or meta fields?
  81. Custom wordpress SQL statement for a website
  82. Where are database files of a WordPress website?
  83. How to create a table [closed]
  84. Getting an error when trying to migrate to DV server from Grid with Media Temple [closed]
  85. WordPress can’t fetch the posts from the database after moving to new server [closed]
  86. why you don’t Implement PDO for access every thing to database
  87. Upload wordpress from localhost to 000webhost
  88. Problem with form database connectivity
  89. Restrict users viewing post using age on database [closed]
  90. How to STOP wordpress trying to update database?
  91. Server database problem
  92. Check for custom field value in different post type than current one and do something
  93. SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
  94. Best way to search and replace within serialized database strings?
  95. WordPress, Error when trying to insert data >> Notice: wpdb::prepare was called incorrectly
  96. Can I connect WordPress website with an external database?
  97. Uploaded images not displaying full size preview or inserting into posts
  98. SQL query to rewrite all media URLs to end with .webp
  99. Cant Connect to Database
  100. What effect can a large wp_post table have on overall site performance?
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
  • 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