Hi @gulliver. 🙂
To start with, copy the parent theme’s entry.php file to your child theme.
In that file, we can find the following code which generates the existing “Edit” link on the front end:
if ( current_user_can( 'edit_post', get_the_ID() ) ) : ?> | <a href="<?php echo ( get_edit_post_link( get_the_ID() ) ); ?>" class="edit-post-link" rel="<?php the_ID(); ?>" title="<?php esc_attr_e( 'Edit', 'p2' ); ?>"><?php _e( 'Edit', 'p2' ); ?></a>
The above code can be used as template for adding a “Delete” link.
The get_edit_post_link() can be replaced with get_delete_post_link(). The last two references to “Edit” can also be replaced so that “Delete” is displayed in a link on the front end:
<php if ( current_user_can( 'edit_post', get_the_ID() ) ) : ?> | <a href="<?php echo ( get_delete_post_link( get_the_ID() ) ); ?>" class="edit-post-link" rel="<?php the_ID(); ?>" title="<?php esc_attr_e( 'Delete', 'p2' ); ?>"><?php _e( 'Delete', 'p2' ); ?></a>
Copy the above snippet below the code for the “Edit” link in your child theme’s entry.php file and let me know how you get on.
Thanks. Sorted.
I also want to add a similar front-end ‘delete’ link for individual comments, but don’t know enough to be able to edit functions.php appropriately.
Adding a link to “Delete” alongside your comments involves some advanced code and goes beyond the scope of support that I’m able to provide.
I did come across some previous related discussion that may help you out if you’d like to experiment with the code in your child theme:
https://wordpress.org/support/topic/adding-delete-post-or-comment-to-your-p2-posts?replies=7#post-1280446
http://wordpress.stackexchange.com/questions/54116/add-delete-approve-spam-links-to-comments
https://www.smashingmagazine.com/2009/07/10-wordpress-comments-hacks/#1-add-action-links-to-comments
If you do decide to have an experiment and come up with a solution, please consider posting back to this thread so that it may help others hoping to achieve the same.
Thanks.
I’ll read the links and experiment.