Deleting records

We have similar methods for deleting records in each of the existing tables as we have for updating records. The following list illustrates a few of the built-in delete functions:

delete_post_meta This deletes custom fields using the specified key in the wp_postmeta table. Accepts post ID, key, and value as parameters.
wp_delete_post This removes existing posts, pages, or attachments from the wp_posts table. Accepts post ID as parameter.
delete_user_meta This removes the metadata matching criteria from a user from the wp_usermeta table. Accepts user ID, key, and value as parameters.

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.