Unable to delete related media attachments with deleted post
Unable to delete related media attachments with deleted post
Unable to delete related media attachments with deleted post
wp_delete_user – huge overhead in Buddypress?
I think it would be helpful if you could explain why you’re generating courses out of edits that a user’s doing on his profile. The simplest solution seems to be a frontend form that just allows a user to create new posts or edit existing ones rather than going for this alternative solution where you’re … Read more
You can use a plugin or edit the .htaccess file yourself (located in the root WordPress directory). Use FTP or your host and edit your .htacess file. Keep in mind, this code will only work if your server is run with Apache. Enter the following code (if you know for sure your server already has … Read more
I realized that I was trying to delete a post while my current site wasn’t the same one. My WordPress is multisite. switch_to_blog($siteId); solved the issue.
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
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
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
There’s a trash post hook add_action( ‘trash_post’, ‘my_func’ ); function my_func( $postid ){ // We check if the global post type isn’t ours and just return global $post_type; if ( $post_type != ‘my_custom_post_type’ ) return; // My custom stuff for deleting my custom post type here }
On the Users (wp-admin/users.php) page, WordPress uses wp_dropdown_users() to generate the users drop-down menu you’re referring to, so I’d suggest using the wp_dropdown_users_args hook to filter the users query, e.g. to show only 1 result (or 10, but surely not 55k!) and then use JavaScript to add/load the other results. So in this answer, I’m … Read more