• I like to use different sidebar for a particular Category 1

    Already I have edited the template, I am using

    l_sidebar.php & r_sidebar.php for home.php

    l_sidebar1.php & r_sidebar1.php for index.php

    Now I need to add

    l_sidebar3.php & r_sidebar3.php for a particular category.

    I edited the index.php

    Original Code

    <?php include(TEMPLATEPATH."/l_sidebar1.php");?>
    
    <?php include(TEMPLATEPATH."/r_sidebar1.php");?>

    Edited Code

    <?php
      if ( in_category('1') ) {
      include(TEMPLATEPATH."/l_sidebar2.php');
    
      } else {
      include(TEMPLATEPATH."/l_sidebar1.php');
    
      }
    ? >
    <?php
      if ( in_category('1') ) {
      include(TEMPLATEPATH."/r_sidebar2.php');
    
      } else {
      include(TEMPLATEPATH."/r_sidebar1.php');
    
      }
    ? >

    and same goes for category 2, 3, 4 .. so on ..

Viewing 3 replies - 1 through 3 (of 3 total)
  • Err, what’s the question? What’s not working?

    And hey, have you seen Category_Templates yet?

    Thread Starter digit4l

    (@digit4l)

    When I tried the above code there was error

    Other possible way, it worked,

    I tried to recall the code as per
    http://codex.wordpress.org/Template_Tags/in_category

    <?php if ( in_category(”) ): ?>
    // PHP or HTML Code
    <?php endif; ?>

    Thread Starter digit4l

    (@digit4l)

    Got Some Error in PHP Code

    <?php if ( in_category(1) || in_category (3) || in_category (5) ) {
    echo ‘<center>HTML Code 1</center>’;
    } else {
    echo ‘<center>HTML Code 2</center>’;
    }
    ?>

    Parse error: syntax error, unexpected T_LNUMBER, expecting ‘,’ or ‘;’ in //public_html/wp-content/themes/default/l_sidebar1.php on line 43

    IF I use like below one : No Error

    <?php if ( in_category(‘1’) || in_category(‘3’) || in_category(‘5’) ): ?>
    <center>HTML Code 1</center>
    <?php endif; ?>

    <center>HTML Code 2</center>

    Please anyone correct the Code …

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Different Sidebar for Particular Category’ is closed to new replies.