WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Twelve
[resolved] Why isnt TwentyTwelve prepared for child-theme? (8 posts)

  1. boldt
    Member
    Posted 1 year ago #

    or for that matter twentyten, and twentyEleven?

    Quote from http://codex.wordpress.org/Child_Themes :

    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.

    http://wordpress.org/extend/themes/twentytwelve/

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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'.

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

  3. Morten Rand-Hendriksen
    Member
    Posted 1 year ago #

    @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.

  4. Tomas Mackevicius
    Member
    Posted 1 year ago #

    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.

  5. Maor Chasen
    Member
    Posted 1 year ago #

    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.

  6. boldt
    Member
    Posted 1 year ago #

    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.

  7. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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.

  8. boldt
    Member
    Posted 1 year ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic