• Hello,

    I am looking to customize by sidebars, and am wondering if there is a fairly easy way to do so with code. I don’t know all that much about code, but I have customized other codes on my site with good results.

    I am aware there is a custom sidebars plugin, but I’m trying to not depend upon plugins too much. And, I’m not sure if it has a way for me to do what I am looking to do or not either.

    There are certain pieces of my sidebar that I am looking to have displayed on all of the pages of my site. This happens automatically by default. However, I am also looking for other pieces of my sidebar to appear only on specific pages. Basically, I’m looking to have things that appear on every page and things that appear only on certain pages there simultaneously.

    Does anyone know how this can be accomplished? Is there a code I can add to my sidebar CSS? Or, is there more to it than that? Thanks in advance for your help!

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter HopefulGJL

    (@hopefulgjl)

    I have discovered something else to add to this information. If you want to call the same sidebar for more than 1 page, then you can use this:

    <?php if (is_page('1'||'2'||'3'||'4'||'5'||'6'||'7')) : ?>
      	<?php get_sidebar('sidebar1'); ?>
      <?php else : ?>
       	<?php get_sidebar(); ?>
      <?php endif; ?>

    With this, page id#’s 1,2,3, etc. are all calling and using sidebar1.

    If you want to specify posts instead of pages, then please read my post here.

    Thread Starter HopefulGJL

    (@hopefulgjl)

    Well, I later learned that for whatever reason, using the above code from my last post somehow affected all of my sidebars on all of my pages, so I went back to listing them individually.

    Oh, and I learned more about how to do custom sidebars for my category/archive ‘pages’ here.

    It’s probably the || ‘s, those shouldn’t be there

    if is_page(‘1,2,3,4,5’) is how that is done

    Thread Starter HopefulGJL

    (@hopefulgjl)

    Thanks for the info…I’ll give that a try.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Code for Custom Sidebars’ is closed to new replies.