Skip to content

Instantly share code, notes, and snippets.

Learning Phoenix (Elixir & Erlang)

Jazib Sawar jazibsawar

Learning Phoenix (Elixir & Erlang)
Block or report user

Report or block jazibsawar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jazibsawar / delete_custom_post_type.php
Created Oct 2, 2017
WordPress $wpdb: Delete all posts of a custom post type with its associated meta data (taxonomies, post meta) using SQL query & $wpdb
View delete_custom_post_type.php
function delete_custom_posts($post_type = 'post'){
global $wpdb;
$result = $wpdb->query(
DELETE posts,pt,pm
FROM wp_posts posts
LEFT JOIN wp_term_relationships pt ON pt.object_id = posts.ID
LEFT JOIN wp_postmeta pm ON pm.post_id = posts.ID
WHERE posts.post_type = %s
You can’t perform that action at this time.