How to properly delete custom post type posts programmatically

I believe I found the problem. Since the wp_delete_post was before the redirect, WordPress tried to reload an inexistent page (and comments, since they are deleted automaticaly with the command) and that generated the error. The new code is as such and it’s not generating errors: if( has_post_thumbnail( $post_id ) ) { $imagem_principal_id = get_post_thumbnail_id( … Read more

Filter DELETE REST API calls

pre_delete_post hook filters whether a post deletion should take place. So callback function must return a boolean value: true – whether to go forward with deletion, false – if not. pre_trash_post hook filters whether a post trashing should take place. So callback function must return a boolean value: true – whether to go forward with … Read more

Remove post if exist by title

The s parameter of WP Query search posts within the title and content columns of the posts table. You can use that to shorten your code. Here is a sample bit to help you get started. You can hook it in wp_footer to run only once (very bad idea to keep it there, but good … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)