• At the moment I have 1 sidebar. Can I make another one? I mean, at the moment sidebar is only at the right side and left side is empty and it would be cool if I could do that…

    What I need to do? I am not a good in IT or programming but maybe someone can help!

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Basic instructions:

    1. Create the template as you would sidebar.php, naming it something obvious like sidebar-2.php or sidebar-right.php.

    2. To include it in theme templates, use:

    <?php include(TEMPLATEPATH . '/sidebar-2.php'); ?>

    or to duplicate the internals of a get_sidebar() sort of include function:

    <?php load_template(TEMPLATEPATH . '/sidebar-2.php'); ?>

    3. That’s pretty much it.

    Thread Starter eipi-radio

    (@eipi-radio)

    First, thanks for that!

    I create a sidebar-right.php and put it on theme (I suppose that was what you mean) but what exactly I need to do next?

    I put that function (<?php include(TEMPLATEPATH . ‘/sidebar-2php’); ?>) in that file ( sidebar-right.php ) but nothing happen… I have a feeling that this function need to be added in some other file, am I right? But I don’t know which file…

    Please advice!

    First, if you are going to call it sidebar-right.php, then you want to change your include to:

    <?php include(TEMPLATEPATH . '/sidebar-right.php'); ?>

    You are including the actual PHP document, so you must use the literal file name of it. TEMPLATEPATH is just a PHP constant that holds the directory path to the active theme directory.

    Second, the include() is placed where you would normally want the sidebar *included*. So you place it in whichever templates in your theme normally have say the get_sidebar() include function.

    Thread Starter eipi-radio

    (@eipi-radio)

    Template is called “Cutline 1.1” and can be found on https://cutline.tubetorial.com/

    Maybe I can copy sidebar-right.php code here so you can see what’s going on (and if it’s correct):

    <div id=”sidebar-right.php”>
    <ul class=”sidebar_list”>
    <?php if (!function_exists(‘dynamic_sidebar’) || !dynamic_sidebar()) : ?>
    <li class=”widget”>
    <h2>Search It!</h2>
    <?php include (TEMPLATEPATH . ‘/searchform.php’); ?>

    <li class=”widget”>
    <h2>Recent Entries</h2>

    <?php if (function_exists(‘get_flickrrss’)) { ?>
    <li class=”widget”>
    <h2><span class=”flickr_blue”>Flick</span><span class=”flickr_pink”>r</span></h2>
    <ul class=”flickr_stream”>
    <?php get_flickrrss(); ?>

    <?php } ?>
    <?php get_links_list(‘id’); ?>
    <?php endif; ?>

    <?php include(TEMPLATEPATH . ‘/sidebar-right.php’); ?>

    I tried to “get_sidebar” function on index.php but then error showed up. I did it because on index.php was “get_sidebar” function for sidebar.php ??

    :/

    Thread Starter eipi-radio

    (@eipi-radio)

    I even tried to step by step follow up various instructions which I found on web but nothing.
    A bit strange thing is that I already have function.php file…But when I go to widgets then it just show first sidebar… :/
    I really don’t know what else do…

    If this:

    <?php include(TEMPLATEPATH . '/sidebar-right.php'); ?>

    is in your sidebar-right.php template, it’s in the wrong place.

    Do not add it to sidebar-right.php. Again, you place it in whichever templates in your theme normally have the get_sidebar() include function. This would typically be index.php, but can include others (single.php, page.php, archive.php, etc.).

    If you are getting an error when doing this, it helps to know what the error is.

    Thread Starter eipi-radio

    (@eipi-radio)

    I put it on index.php and 1 time it showed error , but last 2 times just saved but nothing changed.

    ezgn

    (@ezgn)

    try this
    create sidebar-2.php
    add this function in /wp-includes/general-template.php
    ///////////////////////////////////
    function get_sidebar-2() {
    do_action( ‘get_sidebar’ );
    if ( file_exists( TEMPLATEPATH . ‘/sidebar-2.php’) )
    load_template( TEMPLATEPATH . ‘/sidebar-2.php’);
    else
    load_template( ABSPATH . ‘wp-content/themes/default/sidebar.php’);
    }
    //////////////////////////////////

    ezgn

    (@ezgn)

    and call

    get_sidebar-2();

    where u want

    moshu

    (@moshu)

    We really do NOT encourage modifying the WP core files. So, next time think twice before posting things like this!
    (just a reminder…)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to make 2nd sidebar?’ is closed to new replies.