• Resolved pierremare

    (@pierremare)


    Hi everyone, I hope someone can help. I have trawled the forums and searched everywhere and even though I found a few examples, none have worked for me so far.

    How can I hide the Add New button that appears after you click on pages on the left hand menu and it shows a list of pages already created. Add New appears right next to “Pages”. I have a site for a client where they should not add any new pages. I have already changed the user capabilities so that they can’t publish pages but would really like the button to be gone. CSS or a PHP snippet would be great

    Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • pixellanguage

    (@pixellanguage)

    You can try with this css in admin css:

    .wrap .page-title-action{display:none;}

    Thread Starter pierremare

    (@pierremare)

    Thanks for the tip, where is the admin css? I searched for Admin.css but no specific css file. I did try adding this to my Sparkling theme’s custom css but no luck yet….

    pixellanguage

    (@pixellanguage)

    Thread Starter pierremare

    (@pierremare)

    Thanks for your help pixellanguage, that seemed a bit complicated so I dug a bit deeper and found a solution. The reason the following snippet I found didn’t work is because my current wordpress version has a different class name of .page-title-action (as highlighted by you above – THANKS).

    So I took the following snippet which I found previously:

    //functions.php or add snippet to "Code Snippets" Plugin
          function hide_buttons()
        {
        global $current_screen;
    
        if($current_screen->id == 'page');
        {
        echo '<style>.add-new-h2{display: none;}</style>';
        }
       }
       add_action('admin_head','hide_buttons');

    and I replaced it with:

    //functions.php or add snippet to "Code Snippets" Plugin
      function hide_buttons()
      {
      global $current_screen;
    
      if($current_screen->id == 'page');
      {
      echo '<style>.page-title-action{display: none;}';
      }
    
      }
      add_action('admin_head','hide_buttons');

    So I basically just replaced .add-new-h2 in the first snippet I found with .page-title-action and I would not have even had a clue about this if it wasn’t for your reply, thanks so much.

    The solution above removes the Add New button from post and page listings in Admin area – hopefully someone else may find this useful also.

    pixellanguage

    (@pixellanguage)

    Cool…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to hide Add New Button on page listing’ is closed to new replies.