• CIAGroup

    (@ciagroup)


    Ok so I inserted this code into my functions.php

    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>',
    			) );
    	}
    }

    Now all my categories appear on the right side of the widgets page and I can add widgets to my categories named sidebar, but I can’t figure out how to get them to appear on the page. I read somewhere about a call function, don’t know if I need to use this. There was also another code I was supposed to put in the sidebar.php, but I have no clue where to put it because in the Suffusion theme the left sidebar picks up Sidebar 1 by default, I don’t know how to change or over ride this either. Can anyone help me??

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter CIAGroup

    (@ciagroup)

    Oh sorry I guess I should have specified what I’m trying to accomplish. I have a drop down menu that contains my categories and I want an individual sidebar for each. I used the above code which gave me sidebars with my categories name in the widget section. I just cant figure out how to make them show up.

    WPyogi

    (@wpyogi)

    You might try asking on Suffusion’s dedicated forums:

    https://aquoid.com/forum/

    Thread Starter CIAGroup

    (@ciagroup)

    I posted about it there a few hours ago and still haven’t had a response. I guess I will try again. Thanks.

    Michael

    (@alchymyth)

    Thread Starter CIAGroup

    (@ciagroup)

    I read all that but still don’t understand how to get them to appear on something that is not a page. Like I said they are categories. This is probably the simplest thing and I just can’t figure it out. I have been trying to do this literally ALL day! I don’t give up and don’t ask for help until I absolutely can’t figure it out.

    Thread Starter CIAGroup

    (@ciagroup)

    Let’s see if this helps. Below is the sidebar.php

    <?php
    /**
     * Default (first) sidebar
     *
     * @package Suffusion
     * @subpackage Templates
     */
    
    global $sidebar_alignment, $suf_sidebar_alignment, $suf_wa_sb1_style, $suf_sidebar_1_def_widgets, $suf_sidebar_header;
    
    if (is_page_template('1l-sidebar.php') || is_page_template('2l-sidebars.php') || (is_page_template('1l1r-sidebar.php') && $suf_sidebar_alignment == 'left')) {
    	$sidebar_alignment = 'left';
    }
    else if (is_page_template('1r-sidebar.php') || is_page_template('2r-sidebars.php') || (is_page_template('1l1r-sidebar.php') && $suf_sidebar_alignment == 'right')) {
    	$sidebar_alignment = 'right';
    }
    else if ($suf_sidebar_alignment == 'left') {
    	$sidebar_alignment = 'left';
    }
    else if ($suf_sidebar_alignment == 'right') {
    	$sidebar_alignment = 'right';
    }
    if ($suf_wa_sb1_style != 'tabbed') {
    ?>
    <div class="dbx-group <?php echo $sidebar_alignment;?> <?php echo $suf_wa_sb1_style;?> warea" id="sidebar">
    
    <?php
    	if (!dynamic_sidebar()) {
    				if ($suf_sidebar_1_def_widgets == 'show') {
                                    $before_after_args = array(
    				'after_widget' => '</div></aside><!--widget end -->',
    				'before_title' => '<h3 class="dbx-handle '.$suf_sidebar_header.'">',
    				'after_title' => '</h3>'
    			);
    			                        $before_after_args['before_widget'] = '<!--widget start --><aside id="categories" class="dbx-box suf-widget widget_categories"><div class="dbx-content">';
    			the_widget('WP_Widget_Categories', array('count' => 1), $before_after_args);
    			$before_after_args['before_widget'] = '<!--widget start --><aside id="archives" class="dbx-box suf-widget widget_archive"><div class="dbx-content">';
    			the_widget('WP_Widget_Archives', array('count' => 1), $before_after_args);
    			$before_after_args['before_widget'] = '<!--widget start --><aside id="meta" class="dbx-box suf-widget"><div class="dbx-content">';
    			the_widget('WP_Widget_Meta', array(), $before_after_args);
    		}
    	}
    ?>
    </div><!--/sidebar -->
    <?php
    }
    else {
    ?>
    <div class="tabbed-sidebar tab-box-<?php echo $sidebar_alignment;?> <?php echo $sidebar_alignment;?> warea fix" id="sidebar">
    	<ul class="sidebar-tabs">
    <?php
    	dynamic_sidebar();
    ?>
    	</ul><!--/sidebar-tabs -->
    </div><!--/sidebar -->
    <?php
    }

    What I get out of this is that regardless of what I do it is always going to pick up the default sidebar, 1l-sidebar.php, Which I don’t know how to deactivate. Below is what is in my 1l-sidebar.php

    <?php
    /**
     * Template Name: 1 Left Sidebar (Deprecated)
     *
     * @package Suffusion
     * @subpackage Templates
     */
    
    get_header();
    ?>
    
    <div id="main-col">
    
    <?php if( is_category('8') ) : ?>
    <?php get_sidebar('cvs'); ?>
    <?php else : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>
    
    <?php
    suffusion_page_navigation();
    suffusion_before_begin_content();
    ?>
    	<div id="content">
    <?php
    global $post;
    if (have_posts()) {
    	while (have_posts()) {
    		the_post();
    		$original_post = $post;
    		do_action('suffusion_before_post', $post->ID, 'blog', 1);
    ?>
    		<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    			<?php suffusion_after_begin_post(); ?>
    			<div class="entry-container fix">
    				<div class="entry fix">
    					<?php suffusion_content(); ?>
    				</div><!--/entry -->
    			<?php
    				// Due to the inclusion of Ad Hoc Widgets the global variable $post might have got changed. We will reset it to the original value.
    				$post = $original_post;
    				suffusion_after_content();
    			?>
    			</div><!-- .entry-container -->
    
    			<?php suffusion_before_end_post(); ?>
    
    			<?php comments_template(); ?>
    
    		</article><!--/post -->
    
    <?php
    		do_action('suffusion_after_post', $post->ID, 'blog', 1);
    	}
    }
    ?>
    	</div>
    </div>
    <?php get_footer(); ?>

    And here is where I got the codes I listed in the first post on this page. I don’t know where to place the 2nd code the person provided and I already commented on the post asking where, but haven’t gotten a response.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to "call"’ is closed to new replies.