Support » Theme: Twenty Twelve » [Theme: Twenty Twelve] Why isnt TwentyTwelve prepared for child-theme?

  • Resolved boldt


    or for that matter twentyten, and twentyEleven?

    Quote from :

    TIP FOR THEME DEVELOPERS. The fact that a child theme’s functions.php is loaded first means that you can make the user functions of your theme pluggable —that is, replaceable by a child theme— by declaring them conditionally. E.g.:

    if (!function_exists(‘theme_special_nav’)) {
    function theme_special_nav() {
    // Do something.

    In that way, a child theme can replace a PHP function of the parent by simply declaring it again.

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


    Forum Moderator

    can you be more specific?

    what function(s) are you referring to?

    akaik, all functions in Twenty Twelve are either pluggable, or used in ‘add_filter’ or ‘add_action’.

    Twenty Twelve is possibly the theme with the most children around; and there are a quite a few pluggable functions in Twenty Eleven.

    @boldt: Twenty Twelve is an excellent base for a child theme. In my opinion it is far better than Twenty Eleven because it has less extra ‘baggage’ in the form of rarely used functions and it is also more cleanly written. You can add or remove menus, widgetized areas, hook in new fonts, do whatever you want.

    Most likely @boldt wants to point that one of the most important functions function twentytwelve_setup() in Twenty Twelve lost “if function_exists”.

    In Twenty Ten it had “if function_exists”, so it was easier to replace some of the theme defaults.

    For people who just start coding is much easier to use “if function_exists” rather than play with actions and filters.

    I agree with @tomasm. Although it might be troublesome for some newbies to remove hooks just to personalize the site to their needs, I think it is far more accurate and correct to be able to remove hooks as opposed to having to create every single function they wish to override.

    I think that child-theme is a brilliant idea to modify themes and be able to save my personal changes without making it too complicated to do later update. Here is an example:

    function twentyten_page_menu_args( $args ) {
    $args[‘show_home’] = true;
    return $args;

    (in the above just replace twentyten, with twentyeleven, twentytwelve – its the same function)

    I am making a new WP-site, which will be an online handbook (a lot of Pages -only a few Posts) and I want to replace “Home” in the navigation bar with the word “Instroduction”. In order to do that, I want make the following changes to the function:

    function twentyten_page_menu_args( $args ) {
    $args[‘show_home’] = ‘Introduction’;
    return $args;

    But this is not possible.



    Forum Moderator

    assuming you want to do this for a child of Twenty Twelve;

    in functions.php, this could be done with:

    function twentytwelvechild_page_menu_args( $args ) {
    	$args['show_home'] = 'Introduction';
    	return $args;
    add_filter( 'wp_page_menu_args', 'twentytwelvechild_page_menu_args', 20 );

    the 20 added to to the filter changes the priority so that this is executed after the parent theme’s filters.

    Thank you! It works fine

    I will study further how add_filter() works in order to understand.

    PS. Maybe this should be introduced in the codex on child-themes?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Theme: Twenty Twelve] Why isnt TwentyTwelve prepared for child-theme?’ is closed to new replies.