0
votes

I am new to wordpress and trying to modify a theme I have bought. I am trying to add a custom sidebar to a page template. The page template checks the url of the page and then displays my sidebar if certain conditions are met.

I have added the sidebar to the functions.php file like so

register_sidebar(array(
    'name'=> 'About us',
    'id' => 'td-about', //the id is used by the importer
    'before_widget' => '<aside class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<div class="block-title"><span>',
    'after_title' => '</span></div>'
));

The sidebar is visible in the admin panel in the widgets section of the theme and I have added a custom menu to it.

The page template call the get_sidebar method and I have modified the code of sidebar.php like so

permalink = get_permalink($post->ID);

if (strpos($permalink, 'about') !== false) {

    dynamic_sidebar('td_about');
    } 
    // custom sidebars for pages
        td_util::show_sidebar('page'); <----this is from the theme's code
}

My sidebar is not being displayed on the about us page. The if condition is being met on the about us page as I have checked this. In case it is useful to know, The theme's method td_util:show_sidebar makes calls to dynamic_sidebar to show sidebars from the theme.

thanks a lot

1

1 Answers

2
votes

I believe dynamic_sidebar('td_about') should be dynamic_sidebar('td-about')