how to redirect page after delete post inside a post page?


so on theme single.php i would like to put delete button so that they can delete the post directly. After the post deleted then the page will redirect to profile page.

here is the delete button html

<a class="edit-post" onclick="redirectFunction();" href="<?php bp_loggedinuser_link(); ?>articles/"> Delete </a>

and that is the script for delete the post

perform redirectFunction(){
    <?php wp_delete_post(get_the_id()); ?>

the issue is when i click on different hyperlink that present on page, it also set off this perform to delete the post.

please assist or let me know if there’s any method better than this. thanks

Source link

Leave a Reply