The site is already connected (registered) sidebar. I need to add a new block with text and links to it. And it is also necessary that this block be displayed only on the main page.

Has registered sidebar3 sidebar3 in functions.php . Created a separate sidebar3.php file:

 <div id="left-column"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar3') ) : ?> <?php endif; ?> 

In home.php indicated the path:

 <?php include (TEMPLATEPATH . '/sidebar3.php'); ?> 

In the admin panel on the page widgets added text and links in the widget Sidebar3. But the sidebar is not displayed. What is not doing right? How to display an additional sidebar, but only on the main page?

  • Marina, try not to produce topics, you asked a similar question in a previous topic, to which I answered - eugene_v

2 answers 2

Need to do is_front_page check

  <div id="left-column"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar3') ) : ?> <?php endif; ?> 

If you have registered a sidebar, create a template for it for example sidebar-main.php and sidebar-main.php it <?php is_front_page(get_sidebar('main')); ?> <?php is_front_page(get_sidebar('main')); ?>

    Good day!

    Create a file sidebar-main.php in the theme folder and place the following code:

     <?php //Проверяем наличие сайдбара и выводим его виджеты if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Simple Sidebar") ) : endif; ?> 

    In the functions.php file in your theme folder, add the code:

     <?php //Создаём сайдбар в теме (регистрируем) if ( function_exists('register_sidebar') ) register_sidebar(array( 'id' => 'sidebar-1', 'name' => 'Simple Sidebar', 'before_widget' => '<div class="widget">', 'after_widget' => '</div>', 'before_title' => '<h6 class="widget-title">', 'after_title' => '</h6>', )); ?> 

    In the page template (front-page.php, home.php) add the code in the right place in the sidebar output:

     <?php //Проверяем, главная ли страница у нас показывается if(is_front_page()) { //Выводим сайдбар из файла sidebar-main.php get_sidebar('main'); } ?> 

    More information for you

     <?php include (TEMPLATEPATH . '/sidebar3.php'); ?> 

    Including files via include in wordpress is not welcome, use the get_template_part () function;

    Useful links:

    is_front_page ()

    get_sidebar ()

    get_template_part ()