0

I inherited a site that has had many developers. There are post meta custom post type records for custom post types that we do not have. They appear to have come in through an import when the site was rebuilt in a new host and new theme. Is there a way to remove records in post meta that don't tie to any of our software without breaking the Wordpress Core?

Additional Information Update The records in the postmeta table are tied to active posts and pages. The values in the records are irrelevant to the current site.

1 Answer 1

0

you can achieve this in 2 step

First Step : Remove ORPHANED UNUSED post meta data (SQL Query)

DELETE pm FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL

Second Step INFORMATION : Identify all post meta which is currently set to that post

$meta_values = get_post_meta( get_the_ID() );
echo '<pre>'. print_r($meta_values, 1). '</pre>';

if you found any extra meta, which is not used by your system you can delete it.

delete_post_meta( $post->ID, 'custom_key' );
2
  • I'm new at stack overflow, I don't have enough credit to give you an upvote. I will be trying this solution, thank you for taking the time to answer. Jan 30, 2019 at 21:27
  • I see that my question was not clear, I have updated it. Thank you. Jan 30, 2019 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.