Where to place a certain code in Suffusion Theme
-
I am working with the Suffusions WP theme. Here is my website. On the main menu the tab labeled “Find My Store” has a drop down menu. The items listed in the drop down menu are categories. As you can see I have multiple categories and I would like to be able to customize the side bar on each of these categories. Currently from what I can tell the side bar is controlled by sidebar 1. I’m not an expert with this stuff. I wanted an easier way to define which widget went to which category and so on. So I found a website that gave me the code below to insert into my function.php file:
add_action( 'widgets_init', 'category_sidebars' ); /** * Create widgetized sidebars for each category * * This function is attached to the 'widgets_init' action hook. * * @uses register_sidebar() * @uses get_categories() * @uses get_cat_name() */ function category_sidebars() { $categories = get_categories( array( 'hide_empty'=> 0 ) ); foreach ( $categories as $category ) { if ( 0 == $category->parent ) register_sidebar( array( 'name' => $category->cat_name, 'id' => $category->category_nicename . '-sidebar', 'description' => 'This is the ' . $category->cat_name . ' widgetized area', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); } }
I now have each category listed on the right side when I go to appearance and select widgets. Which is exactly what I want, but I have no clue where to enter the following code in the sidebar.php file:
$sidebar_id = ( is_category() ) ? sanitize_title( get_cat_name( get_query_var( 'cat' ) ) ) . '-sidebar' : 'sidebar';
dynamic_sidebar( $sidebar_id );
I am not an expert at all this coding, CCS, etc. Can anyone help explain this to me in “blonde” persons terms?
- The topic ‘Where to place a certain code in Suffusion Theme’ is closed to new replies.