I have this code to remove orphaned posts after deleting custom post type.
It works, but this code...
global $wpdb;
$wpdb->query(
$wpdb->prepare(
"DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID=b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID=c.post_id)
WHERE a.post_type='attorneys'"
)
);
...is throwing this error:
PHP Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder.
So, after reading the explanation on make.wordpress.org by Andrew Nacin, I (sorta) gather that ...well.. I'm missing the second argument.
Then after reading this stack post, I'm wondering if I even need the prepare()
function. Are there any variables holding unknown values? I'm not clear on this.
...what am I missing?
UPDATE: This code also works, but w/o the prepare() I wonder if its safe.
global $wpdb;
$wpdb->query(
"DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID=b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID=c.post_id)
WHERE a.post_type='attorneys'"
);
Please advise.