Unknown Post Meta Records

admin2025-06-03  2

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.

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.

Share Improve this question edited Jan 30, 2019 at 21:39 TechTurtle2 asked Jan 28, 2019 at 21:41 TechTurtle2TechTurtle2 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 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' );
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748959728a315170.html

最新回复(0)