Hi Johan. Thank you for your info (and for your donation! :-)). I’ll def look to add this functionality in a future release.
Hi Johan. I’ll be releasing a fix for your linked post status issue mentioned above later tonight. π
I’ve had a think about your ‘delete linked post’ request. I have some reservations about putting this into the core without giving the user some options on this so I’m going to have a further think about how to manage this. However if you wish to implement this functionality simply add the following code into your functions.php file in your theme π
function mpd_trash_linked_posts($post_id){
if (function_exists('mpd_get_persists_for_post')) {
$linked = mpd_get_persists_for_post(get_current_blog_id(), $post_id);
foreach ($linked as $linked_post) {
switch_to_blog($linked_post['destination_id']);
wp_trash_post( $linked_post['destination_post_id'] );
restore_current_blog();
}
}
}
add_action('trash_post', 'mpd_trash_linked_posts');
Thank you MagicStick. I’ll test it tomorrow and Let you know how the code works. Cheers π
I think it would be an awesome feature to add the posibilities to delete posts or change poststatus. I understand that it needs som thinking and take your time on this.
Btw I’m going to translate it to Swedish. π
Hello MagicStick.
Tried your code now. It seems to work nearly perfect. When I change poststatus, everything works great. But when I try to delete I get the following:
Fatal error: Cannot use object of type stdClass as array in /home/xxx/public_html/wp-content/themes/mytheme/functions.php on line 83
It’s still a great start. Any suggestions how to fix this? Line 83 is this piece of code:
switch_to_blog($linked_post[‘destination_id’]);
The post is deleted from the main site despite the error, but on the other sites the post is published to, the post remains intact and is not deleted.
Thanks for all the help.
Kind regards
Johan π
My bad. This should work:
function mpd_trash_linked_posts($post_id){
if (function_exists('mpd_get_persists_for_post')) {
$linked = mpd_get_persists_for_post(get_current_blog_id(), $post_id);
foreach ($linked as $linked_post) {
switch_to_blog($linked_post->destination_id);
wp_trash_post( $linked_post->destination_post_id );
restore_current_blog();
}
}
}
add_action('trash_post', 'mpd_trash_linked_posts');
Thank you MagicStick. That works perfectly. For your notice (it’s not an issue for me) when a post or page is deleted linked post is deleted as well. So far soo good. When you permanently delete a post, it will not be permanently deleted on the other multisite blogs.
No issue for me, but just want to inform you about this π
All the best to you!
Regards
Johan