0

I want to create a child theme and sanitize the menu. The steps I followed are:

  • I created a folder called twentyfourteen_child
  • created a CSS folder and added to it style.css
  • created a functions.php file in the twentyfourteen-child with the code below
  • in the wordpress settings I changed the theme to twentyfourteen-child

According to the documentation (https://codex.wordpress.org/Function_Reference/remove_menu_page) that should work:

<?php

if(!function_exists('twentyfourteen_child_setup')){
 function twentyfourteen_child_setup() {
    remove_menu_page( 'edit.php' );                   //Posts
    remove_menu_page( 'upload.php' );                 //Media
    remove_menu_page( 'edit.php?post_type=page' );    //Pages
    remove_menu_page( 'edit-comments.php' );          //Comments
    remove_menu_page( 'tools.php' );                  //Tools
    remove_menu_page( 'themes.php' );                 //Appearance
        remove_menu_page( 'plugins.php' );                //Plugins
 }
}
add_action( 'admin_menu', 'twentyfourteen_child_setup');
?>

but it doesn't. My admin menu still show all the items.

Any ideas why? Am I doing anything wrong?

I added few print_r statements but none of them are logging anything. It looks like functions.php might be not read by the system?

Janusz Chudzynski
  • 2,700
  • 3
  • 33
  • 46
  • are you sure that those are the slugs? – Michal S Mar 11 '14 at 20:24
  • No. How can I find the slugs for the specific theme? I am using 2014. – Janusz Chudzynski Mar 11 '14 at 20:47
  • 1
    look at http://justintadlock.com/archives/2011/06/13/removing-menu-pages-from-the-wordpress-admin but you know that this is all about admin menus? – Michal S Mar 11 '14 at 21:00
  • Thanks for quick answer. Yes, I would like to clean up menu. No luck so far even after reading your article. I put several print_r statements in the functions.php of my child them e but I don't see any output. Perhaps my theme doesn't read functions.php file ??? – Janusz Chudzynski Mar 11 '14 at 21:15
  • Never herd of not reading functions.php, but put in it something easy to test like my code for widget ;) from http://stackoverflow.com/questions/22217831/how-to-show-wordpress-admin-menus-in-a-custom-dashboard-widget/22219601#22219601 – Michal S Mar 11 '14 at 21:20
  • I am sure I am doing something simple and stupid. I copied your code to my functions.php and don't see anything new. – Janusz Chudzynski Mar 11 '14 at 21:33
  • no new widget in dashboard? – Michal S Mar 11 '14 at 21:39
  • Hmm no. http://imgur.com/Gyw2Cwr – Janusz Chudzynski Mar 11 '14 at 21:44
  • sorry, for this question but you editing functions.php in right template folder? Please put die('lipa'); in it. – Michal S Mar 11 '14 at 21:54
  • I am editing the file in wp-content/themes/twentyfourteen-child folder. It includes only the functions.php file and Css folder. Changes to the styles.css from the css folder are reflected immediately. But changes to the functions.php don't have any effect. I just added some gibbrish code to it and still nothing. – Janusz Chudzynski Mar 11 '14 at 22:17
  • try deactivate plugins, if no change reinstall (manually) wp files. – Michal S Mar 11 '14 at 22:22
  • I found out what's wrong. Thank you for your help! – Janusz Chudzynski Mar 12 '14 at 17:54

1 Answers1

1

My problem was invalid file structure of the files. My style.css was in the css folder.

theme/Css/style.css while functions.php was in the theme folder.

Once I moved style.css to the root folder of theme everything started working fine... Wow. It took me around 10h to fight with it.

Janusz Chudzynski
  • 2,700
  • 3
  • 33
  • 46