WordPress.org

Ready to get started?Download WordPress

Forums

Simple Catch
[resolved] Different sidebar in homepage (6 posts)

  1. fotonarya
    Member
    Posted 1 year ago #

    I would like to have a different sidebar for the posts page then the static front page. Using widgets on both.
    I already have simple catch child theme and add this code in function.php

    if ( function_exists( 'register_sidebar' ) ) {
    	register_sidebar( array(
    		'name'          => __( 'Home', 'simplecatch' ),
    		'id'            => 'home',
    		'description'   => __( 'Sidebar homepage', 'simplecatch' ),
    		'before_widget' => '<div class="widget">',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h3>',
    		'after_title'   => '</h3><hr/>'
    	) );
    }

    and replace this code in sidebar.php

    if ( function_exists( 'dynamic_sidebar' ) ) {
    		//displays 'sidebar' for all pages
    		dynamic_sidebar( 'sidebar' );
    	}
    	?>

    with this code

    if ( function_exists('dynamic_sidebar')):
    		if (is_home())
    			dynamic_sidebar('home');
    		else dynamic_sidebar('sidebar');
    		endif;

    but it's doesn't work :(
    Please advice....

    Thanks,

    http://wordpress.org/extend/themes/simple-catch/

  2. satty005
    Member
    Posted 1 year ago #

    you don't need to replace the code in sidebar.php code but add this code in index.php or where it sidebar.php is being included.

  3. fotonarya
    Member
    Posted 1 year ago #

    @satty005 already add the code to index.php, but still cannot get this work.
    Please tell me, what exactly i have to do
    I'm not a kind of expert in this coding world

    Thanks,

  4. Catch Themes
    Member
    Theme Author

    Posted 1 year ago #

    @fotonarya: Four function.php code looks fine. But your sidebar.php should be like this:

    global $post;
    	if( $post )
    		$layout = get_post_meta( $post->ID,'simplecatch-sidebarlayout', true ); 
    
    	if( empty( $layout ) || ( !is_page() && !is_single() ) )
    		$layout='default';
    
    	global $simplecatch_options_settings;
        $options = $simplecatch_options_settings;
    
    	$themeoption_layout = $options['sidebar_layout'];
    
    	if( $layout=='left-sidebar' ||( $layout=='default' && $themeoption_layout == 'left-sidebar') ) {
    		echo '<div id="sidebar" class="col4 no-margin-left">';
    	} else {
    		echo '<div id="sidebar" class="col4">';
    	} 
    
    	if ( function_exists( 'dynamic_sidebar' ) ) {
    		if  ( is_home() || is_front_page() ) {
    			//displays 'sidebar' for all pages
    			dynamic_sidebar( 'home' );
    		} else {
    			//displays 'sidebar' for all pages
    			dynamic_sidebar( 'sidebar' );
    		}
    	}
    
    	?>
    	</div><!-- #sidebar -->
    
    	<?php
    	if(!( $layout=='left-sidebar' ||( $layout=='default' && $themeoption_layout == 'left-sidebar') ) ) {
    		echo '<div class="row-end"></div>';
    	}
  5. fotonarya
    Member
    Posted 1 year ago #

    @sakin thanks, you are rock
    your code work like a champ

    and thanks again for the great theme

  6. fotonarya
    Member
    Posted 1 year ago #

    *forgeted to mark it with resolved*

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic