X

Comment supprimer les liens Modifier, Voir, Corbeille et Modifier rapidement dans l’administration des articles ?

Snippets by IsItWP

Vous cherchez un moyen de supprimer les liens d’édition, de visualisation, de corbeille et d’édition rapide que vous voyez lorsque vous passez la souris sur un article ? Bien qu’il existe probablement un plugin pour cela, nous avons créé un extrait de code rapide que vous pouvez utiliser pour supprimer les liens d’édition, de visualisation, de corbeille et d’édition rapide dans l’administration des articles sur WordPress.

Instructions:

Tout ce que vous avez à faire est d’ajouter ce code dans le fichier functions.php de votre thème ou dans un plugin spécifique à votre site:

add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );
function remove_row_actions( $actions )
{
    if( get_post_type() === 'post' )
        unset( $actions['edit'] );
        unset( $actions['view'] );
        unset( $actions['trash'] );
        unset( $actions['inline hide-if-no-js'] );
    return $actions;
}

Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez vous référer à notre guide sur comment copier/coller correctement des extraits de code dans WordPress, afin de ne pas casser accidentellement votre site.

Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : 7 meilleurs plugins WordPress de calendrier et comment démarrer un blog WordPress.

Commentaires   laisser une réponse

  1. It’s should on page one !

  2. it does not works

  3. it doesn’t work for post_type = ‘page’, but working smoothly for custom post type. Any solution for this? thx before

  4. Thanks a lot..

  5. How can I make these columns appear on a custom columns that I’ve added.

    I am adding a Testimonial post, which doesn’t support title in my case. And, hence I want to be able to show all options “the link, edit, trash, view, delete” links that appear on Title column to appear on this new column – Client name.

  6. Thanks for this. Was looking all over the place for this. 

  7. Funny Facebook Status novembre 20, 2011 à 8:24 am

    Any idea how to add Trash link in main Index Page.. Thanks.. 

  8. Funny Facebook Status novembre 20, 2011 à 8:23 am

    dsadas

  9. thanks for the snippet.. but how can i disable the hyperlink of the tittle of the post

    1. Ill take a look and see if this is a snippet I can post in the future.

  10. Great snippet – thanks

    Anyway to get this to work with a custom post type also though?

    1. You will notice on line 04:  if( get_post_type() === ‘post’ )  the post type is post if you change that to the custom post type name that should do it. However if you want to apply to every post and post type just remove line 04 altogether.

      1. (belated!) thanks, much appreciated

        1.  No problem Glad that I could help.

    2. Just thought about this as well, you could remove them for everyone but a set number of users, replace line 04 with the following.

      global $current_user;
      get_currentuserinfo();
      // change users in list
      $users = array(
      “dave”,
      “larry”,
      “steve”,
      “ryan”
      );
      if (!in_array($current_user->user_login, $users))

      Add new users that are allowed to see the edit, view, trash buttons etc.

  11. Great code snippet!  Would love to know how to remove the “trash” function housed above the list of posts, as well as on the edit post page.  basically, I want to take away any users ability to trash ANY post. thanks!

    1. Grant glad you like the snippet, in regards to your request you could always insert CSS using the admin_head hook and display none the class=”delete-action” would not disable the function but would hide the button. You can see this snippet to get the idea just change the css used.

      http://wpsnipp.com/index.php/functions-php/change-custom-post-type-icon-for-new-and-edit-post-pages/

      1.  You probably discourage this type of request. I am trying to add this snippet to WP. I am a PHP virgin and have messed up the syntax on inserting the code. I am an amateur at SQL and thought I could apply my limited knowledge process to this and I’ve fouled up”  I’ve placed it at the end of the /public_html/wp-content/themes/twentyten function file. I can’t get the closing syntax correct.  Do I need to add an endif; to close the file? Or, should I paste the snippet into a different location in the file.  I appreciate your help.

        1. @SurfinUSA:disqus you will notice within the functions.php at the start you have a the location does not matter for this snippet but it needs to be between the of the file.

          1. Kevin,

            I’m sorry. The symbols you used to designate where the snippet must be located did not appear either on your web page or in the confirming e-mail I received below.  Could you find another way to indicate the location where I need to insert the snippet?

        2. You can view a simple sample here,
          http://pastebin.com/0hVSQchQ

          Your functions.php would be bigger then this but the register code at the top should be there, just replace the code here with the code above.

          1. Thanks Kevin

            It works fine now

Ajouter un commentaire

Nous sommes heureux que vous ayez choisi de laisser un commentaire. N'oubliez pas que tous les commentaires sont modérés conformément à notre privacy policy, et que tous les liens sont en nofollow. N'utilisez PAS de mots-clés dans le champ du nom. Engageons une conversation personnelle et constructive.

WordPress Launch Checklist

L'ultime liste de contrôle pour le lancement de WordPress

Nous avons rassemblé tous les éléments essentiels de la liste de contrôle pour le lancement de votre prochain site Web WordPress dans un ebook pratique.
Oui, envoyez-moi le gratuit !