Home > CMS Tutorial > WordPress > body text

How to delete articles in wordpress frontend

Release: 2019-07-22 14:01:08
Original
2596 people have browsed it

How to delete articles in wordpress frontend

The function of deleting articles directly on the front desk of the website is realized through a php function. It is estimated that there are very few people who need this function;

Because a local one is built Collection station, if you want to delete the articles you have read with one click, you can improve the work effect;

Put the following function into the custom position of single.php article content page, so that when you click on the article in the front browser Deleting it will quickly achieve what we want;

<?php   
$url = get_bloginfo(&#39;url&#39;);   
  if (current_user_can(&#39;edit_post&#39;, $post->ID)){   
    echo &#39;<a class="delete-post" href="&#39;;
    echo wp_nonce_url("$url/wp-admin/post.php?action=delete&post=$id", &#39;delete-post_&#39; . $post->ID);  
    echo &#39;"><strong>删除文章</strong></a>&#39;;   
  }   
?>
Copy after login

For more wordpress related technical articles, please visit the wordpress tutorial column to learn!

The above is the detailed content of How to delete articles in wordpress frontend. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template