New general-template.php in 2.7 (3 posts)

  1. bottleneck
    Posted 7 years ago #

    Hi, everyone.

    I got a few sidebar templates since WP 2.2 . They all worked fine through WP 2.6 ( I tweaked general-template.php)

    Yet I got stuck with the newest general-template.php in 2.7.

    To be short, how do I need to tweak the code to get "special" (as they put it) specified?

    The piece of general-template.php 2.7 code follows:

     * Load sidebar template.
     * Includes the sidebar template for a theme or if a name is specified then a
     * specialised sidebar will be included. If the theme contains no sidebar.php
     * file then the sidebar from the default theme will be included.
     * For the parameter, if the file is called "sidebar-special.php" then specify
     * "special".
     * @uses locate_template()
     * @since 1.5.0
     * @uses do_action() Calls 'get_sidebar' action.
     * @param string $name The name of the specialised sidebar.
    function get_sidebar( $name = null ) {
    	do_action( 'get_sidebar' );
    	$templates = array();
    	if ( isset($name) )
    		$templates[] = "sidebar-{$name}.php";
    	$templates[] = "sidebar.php";
    	if ('' == locate_template($templates, true))
    		load_template( get_theme_root() . '/default/sidebar.php');

    All my attempts return "Call to undefined function ..." so far..

  2. To be short, how do I need to tweak the code to get "special" (as they put it) specified?

    If you have a custom sidebar in your theme, named "sidebar-special.php", then a theme template (like single.php or index.php or archive.php, etc) can call get_sidebar('special'); to get that sidebar. Normally, themes call get_sidebar(); without any parameters.

    If you call get_sidebar('special'); and no sidebar-special.php exists in the theme, it'll get the normal sidebar.php instead.

  3. bottleneck
    Posted 7 years ago #

    Thanks, Otto.

    I would've tweaked that file all my life having no clue that no tweak is needed :)

    Everything works!

Topic Closed

This topic has been closed to new replies.

About this Topic