I've built a membership site where users can post listings from the frontend, edit those, and ideally also delete them.
For the latter, I'd like to echo a "delete post" link to the frontend. The problem is that
So from this:
$theID = get_the_ID(); // inside loop
<a href="<?php echo get_delete_post_link( $theID, '', false ); ?> ">Delete This Post</a>
123 /* = $theID; */
<a href="_">Delete This Post</a>
I tried the following things:
- passing only $theID as argument instead of the full three
$theID, '', true
- ran checks as described in the answers here: Can't echo get_delete_post_link
- the problem occurs both when I'm logged in as admin and as normal user (with added capacities)
- I made sure the permissions for the custom post type are mapped correctly
- outside the loop it works, but not inside the loop (the codex says it can be done within the loop: https://codex.wordpress.org/Function_Reference/get_delete_post_link).
Here's the loop I'm using:
// arguments $arguments = array( 'post_type' => 'CustomType', 'posts_per_page' => -1, 'author_name' => $current_user->user_login ); // query $the_query = new WP_Query($arguments); <?php wp_reset_query(); // Restore global post data stomped by the_post(). ?> <?php if( $the_query->have_posts() ): ?> <?php while( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php if( has_term( 'custom_term', 'custom_taxonomy' ) ): ?> /* stuff happens here */ /* get_delete_post_link() returns nothing */ <?php endif; ?> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
I'm at the end of my wits with this, any help would be appreciated.