Title: get_delete_post_link
Published: April 25, 2014
Last modified: August 20, 2026

---

# get_delete_post_link( int|WP_Post $post, string $deprecated = '', bool $force_delete = false ): string|null

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#wp--skip-link--target)

Retrieves the delete posts link for post.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#description)󠁿

Can be used within the WordPress loop or outside of it, with any post type.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#parameters)󠁿

 `$post`int|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
optional

Post ID or post object. Default is the global `$post`.

`$deprecated`stringoptional

Not used.

Default:`''`

`$force_delete`booloptional

Whether to bypass Trash and force deletion.

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#return)󠁿

 string|null The delete post link URL for the given post.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#source)󠁿

    ```php
    function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = false ) {
    	if ( ! empty( $deprecated ) ) {
    		_deprecated_argument( __FUNCTION__, '3.0.0' );
    	}

    	$post = get_post( $post );

    	if ( ! $post ) {
    		return null;
    	}

    	$post_type_object = get_post_type_object( $post->post_type );

    	if ( ! $post_type_object ) {
    		return null;
    	}

    	if ( ! current_user_can( 'delete_post', $post->ID ) ) {
    		return null;
    	}

    	$action = ( $force_delete || ! EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';

    	$delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );

    	/**
    	 * Filters the post delete link.
    	 *
    	 * @since 2.9.0
    	 *
    	 * @param string $link         The delete link.
    	 * @param int    $post_id      Post ID.
    	 * @param bool   $force_delete Whether to bypass the Trash and force deletion. Default false.
    	 */
    	return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/link-template.php#L1556)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/link-template.php#L1556-L1591)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#hooks)󠁿

 [apply_filters( ‘get_delete_post_link’, string $link, int $post_id, bool $force_delete )](https://developer.wordpress.org/reference/hooks/get_delete_post_link/)

Filters the post delete link.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#related)󠁿

| Uses | Description | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [_deprecated_argument()](https://developer.wordpress.org/reference/functions/_deprecated_argument/)`wp-includes/functions.php` |

Marks a function argument as deprecated and inform when it has been used.

  | 
| [wp_nonce_url()](https://developer.wordpress.org/reference/functions/wp_nonce_url/)`wp-includes/functions.php` |

Retrieves URL with nonce added to URL query.

  | 
| [add_query_arg()](https://developer.wordpress.org/reference/functions/add_query_arg/)`wp-includes/functions.php` |

Retrieves a modified URL query string.

  | 
| [admin_url()](https://developer.wordpress.org/reference/functions/admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for the current site.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  | 
| [get_post_type_object()](https://developer.wordpress.org/reference/functions/get_post_type_object/)`wp-includes/post.php` |

Retrieves a post type object by name.

  |

[Show 6 more](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#)

| Used by | Description | 
| [WP_Posts_List_Table::handle_row_actions()](https://developer.wordpress.org/reference/classes/wp_posts_list_table/handle_row_actions/)`wp-admin/includes/class-wp-posts-list-table.php` |

Generates and displays row action links.

  | 
| [post_submit_meta_box()](https://developer.wordpress.org/reference/functions/post_submit_meta_box/)`wp-admin/includes/meta-boxes.php` |

Displays post submit form fields.

  | 
| [attachment_submit_meta_box()](https://developer.wordpress.org/reference/functions/attachment_submit_meta_box/)`wp-admin/includes/meta-boxes.php` |

Displays attachment submit form fields.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.9.0](https://developer.wordpress.org/reference/since/2.9.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/get_delete_post_link/?output_format=md#comment-content-4584)
 2.   [Yohann Billard](https://profiles.wordpress.org/byohann6/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/get_delete_post_link/#comment-4584)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_delete_post_link%2F%23comment-4584)
    Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_delete_post_link%2F%23comment-4584)
 4. Be careful, if you use this function with a custom post type, you must define the“
    show_ui” parameter of the [register_post_type()](https://developer.wordpress.org/reference/functions/register_post_type/#show_ui)
    function to true.
 5. With “show_ui” parameter to false, link doesn’t work
     `https://example.com/wp-admin/?
    action=delete&_wpnonce=bb70aa97e2`
 6. With “show_ui” parameter to true, link works
     `https://example.com/wp-admin/post.
    php?post=1234&action=delete&_wpnonce=87d5108013`
 7.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_delete_post_link%2F%3Freplytocom%3D4584%23feedback-editor-4584)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_delete_post_link%2F)
before being able to contribute a note or feedback.