WordPress.org

Ready to get started?Download WordPress

Forums

Different sidebar per page (3 posts)

  1. mraquinn
    Member
    Posted 5 years ago #

    Hi,

    Is there a clean way to have a different side bar, or content in the side bar for a range of pages?

    I have a range of 10 products and in the sidebar I want to put the spec for each product.

    The only way I can think of is to have a template for each product page and put the spec data in each template - ie. have 10 templates.

    Surely there is a better way?

  2. asechrest
    Member
    Posted 5 years ago #

    Not sure what form of information you need to put in the sidebar, but the Widget Logic plugin might work for you.

    If you can add the product information to a text or other type of widget (FYI various plugins allow full PHP code in text widgets; Otto from these forums has a good one, Exec-PHP is another good one), you could then use Widget Logic to force a certain widget to appear only on a certain page(s) using is_page().

  3. asechrest
    Member
    Posted 5 years ago #

    Alternatively, you could hardcode your sidebar.php or page.php files to get the same functionality, using if statements and is_page().

    For a similar example, I use a custom Google search on my site, but Google doesn't allow the results to be any less than 795px wide, which is nearly the width of my content div PLUS my sidebars. So in page.php, I check to see if I'm on the search results page, and if so, I block the sidebar generation for that page.

    These are the only ways I'm familiar with. Someone with some coding experience might have a better way.

Topic Closed

This topic has been closed to new replies.

About this Topic