Title: Function.php in child theme twentyten
Last modified: August 20, 2016

---

# Function.php in child theme twentyten

 *  Resolved [jimii](https://wordpress.org/support/users/jimii/)
 * (@jimii)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/)
 * I’m trying to append the code below into a child twentyten theme. It works fine/
   does its job when in the parent on its own. However when I try to make it work
   solely in the child theme I cannot get it to provide the proper result – ie the
   code doesn’t do its job of hiding the media library tab. I believe I’m missing
   something in the proper setup of a function.php in a child theme… If anyone is
   able to provide any guidance on this I would be grateful. (i can find step by
   step on css but not on function.php for child)
 *     ```
       function remove_medialibrary_tab($tabs) {
        unset($tabs['library']);
        return $tabs;
        }
        if(!current_user_can(‘update_core’))
       add_filter(‘media_upload_tabs’,'remove_medialibrary_tab’);
       ```
   
 * In trying ot solve this myself I’ve reviewed the basic wordpress docs on function.
   php in a child theme – I understand this does not simply work like style.css 
   in a child theme and further that while its noted as being “plugable” to the 
   parent – Im not skilled enough in php code at present to know how to execute 
   as a plugable command.)
 * Any help on this or guidance to an online resource that i can read or adapt would
   be appreciated. thank you.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/#post-3094974)
 * You have some single curly quotes (`‘’`)in your code try it with:
 *     ```
       function remove_medialibrary_tab($tabs) {
        unset($tabs['library']);
        return $tabs;
        }
        if(!current_user_can('update_core'))
       add_filter('media_upload_tabs','remove_medialibrary_tab');
       ```
   
 * This code will remove the library link when adding new media in the edit/publish
   post screen.
 * Does your parent theme have the exact same function (remove_medialibrary_tab)
   name?
 *  Thread Starter [jimii](https://wordpress.org/support/users/jimii/)
 * (@jimii)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/#post-3095019)
 * hello keesiemeiger, thank you very much for your quick reply and help.
 * I’ve switched the code to the ‘quote’ style you ref above – but as before – i
   am only able to get it to work when placing the code into the parent theme’s 
   function php, but not in the child.
 * Correctly as you say – the code is inteded to hide the media library – its going
   on a multi user site – so uploaders of property pics – only see and have access
   to their own pics.
 * If i understand your question correctly – the parent theme itself doesnt have
   a function name for this to my knowledge ….?
 * The primary removal of the media gallery from the WP admin menu is being done
   by a Menu Admin plugin. It doesnt however take out / unseat the media library
   tab in the edit/publish post screen as you reference above – and so thus the 
   addon code to remove that accesss/view space. Is it possible – because the plugin
   is functioning within the parent theme – the addon code wont work in the child
   theme? (doesnt seem to make sense to me either)
 * Two other bit of information i can throw out; the site is in redevelopment so
   its on a temp url – but i dont think that would matter.
 * Secondly – as it realtes to the child php file – there is littel to no information
   on the need for preamble information in the file – like setting up a child css.
   So I’ve tried it with just the code and also with the full function.php data 
   from the parent. But regardless should it also have the bit of code like the 
   css file [@import](https://wordpress.org/support/users/import/)…. if this makes
   any sense??
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/#post-3095047)
 * [http://vudu.me/child](http://vudu.me/child) – I’m not sure if anything in my
   article might help you, it’s very basic
 * funtions.php loads from the parent and child. So, you basically have a functions.
   php file like this to start in your child
 *     ```
       <?php
   
       // Custom code goes here
       ```
   
 * And that’s it to start. You wouldn’t copy things from parent to child directly
   for many things – there are exceptions of course
 * You just put your own custom code in to your child functions file
 * Since you aren’t actually trying to override anything out of the parent functions
   file, I won’t elaborate on how to do that here
 * I will try to research your issue a bit more…. I just wanted to throw out that
   bit of info, hoping to clarify how that file works
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/#post-3095052)
 * I might be doing the same thing here – but your conditional looks out of whack
   to me – but I’m far from a pro!
 *     ```
       function remove_medialibrary_tab($tabs) {
           	if ( !current_user_can( 'update_core' ) ) {
           		unset($tabs['library']);
           		return $tabs;
           	}
           }
           add_filter('media_upload_tabs','remove_medialibrary_tab');
       ```
   
 * Or the conditional on the actual filter as you have it – what throws me is the
   lack of curly braces on your original conditional
 *     ```
       function remove_medialibrary_tab($tabs) {
       	unset($tabs['library']);
        	return $tabs;
       	}
       if( !current_user_can('update_core')) {
       	add_filter('media_upload_tabs','remove_medialibrary_tab');
       }
       ```
   
 * I honestly am unsure how necessary that might be – I only code based on patterns
   I’m used to
 *  Thread Starter [jimii](https://wordpress.org/support/users/jimii/)
 * (@jimii)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/#post-3095123)
 * Thank you both for your efforts and ideas.
 * I tried all the suggestions above – in combinations with opening php tage – opening
   and closing tags – without success.
 * Im still sourcing and reading other resources to try and figure this out. If 
   there is anything else i can provide here that might shed some light please let
   me know. thank you again
 *  Thread Starter [jimii](https://wordpress.org/support/users/jimii/)
 * (@jimii)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/#post-3095157)
 * Just to let you know that I was unable to get the function.php code edit working
   in the child theme but have resolved it by inserting the code into a newly create
   plugin.
 * I had never done this before – it sounded like it might be too complex for me
   to figure out. Long story short – with a basic plugin format I found on a site
   called brave new code i was able to create a plugin for my site that resolved
   this issue.
 * In hindsight and with review of other tutorials it makes sense, given that functions.
   php ‘acts like a plugin’ and – both the original plugin auther and the php code
   author made reference to plugin options.
 * I still don’t know specifially why the child theme didnt work but can only guess
   that in some fashion as a filter / hook it required access to more than just 
   the information in the function.php file of the parent theme. I dont know if 
   this makes sense all – but its all i can surmise logically. Anyway – just a note
   to advise resolved. thank you.
 *  Thread Starter [jimii](https://wordpress.org/support/users/jimii/)
 * (@jimii)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/#post-3095251)
 * Just to share that while i resolved this a month ago by creating a plugin – Just
   today I figured out the actual cause of the code edit being non-responsive in
   the child theme but working in the parent.
 * Had a similar problem today with a function php edit i was trying to make. It
   would work in parent but not in child. Something finally dawned on me to check
   the file name extension for functions.php. It was then i noted the child theme
   file was set-up with function versus functions .. (singular versus plural) a 
   simple spelling issue.
 * For anyone else with a similar issue – check the case and spelling – it will 
   save a fair bit of time. :\

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Function.php in child theme twentyten’ is closed to new replies.

## Tags

 * [child theme](https://wordpress.org/support/topic-tag/child-theme/)
 * [function.php](https://wordpress.org/support/topic-tag/function-php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [jimii](https://wordpress.org/support/users/jimii/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/functionphp-in-child-theme-twentyten/#post-3095251)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
