Treehouse: Grow your CSS skills. Land your dream job.

WordPress…no sidebars…’sidebar’ for each post?

  • # December 12, 2008 at 11:38 pm

    I want to put together a WordPress theme where I don’t use the traditional sidebar but rather give each post it’s own ‘sidebar’ where I put links related to that particular post. Anyone know how to do this? Has it been done elsewhere?

    # December 13, 2008 at 9:05 pm

    A quick google search for ‘related posts widget’ should sort you out. Here’s one…

    You’ll need to create an extra sidebar module to use the widget only in single.php. Here’s the easy way….

    Add this to your functions.php file.

    if ( function_exists(‘register_sidebar’) )
    ‘before_widget’ => ‘
  • ‘,
    ‘after_widget’ => ‘
  • ‘,
    ‘before_title’ => ‘

    ‘after_title’ => ‘


then add this to single.php where you want the widget to appear.

    < ?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('related') ) : ?>
    < ?php endif; ?>

Choose ‘related’ from the drop down menu in Themes->Appearance->Widgets and add the ‘related posts’ widget to that sidebar module.


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.