ThemeShaper Forums » Thematic

[closed]

Remove sidebar

(14 posts)
  • Started 5 years ago by alx43
  • Latest reply from helgatheviking
  • This topic is resolved
  1. alx43
    Member

    Hi,
    Regarding the kill sidebar function:

    function kill_sidebar() {
    if (is_page('1')) {
    return FALSE;
    } else {
    return TRUE;
    }
    }
    add_action('thematic_sidebar', 'kill_sidebar');

    Is there a way to selectively remove sidebar and in the same time increase the width of the content so that it occupies the empty space left by removing the sidebar?
    Thanks

    *fixed the code above: Chris 02/11/2010

    Posted 5 years ago #
  2. Hi,

    this sidebar part will be done automatically. The primary or secondary will only show up if you connect at least one widget.

    If you would like to switch off primary or secondary for a certain condition, try Widget Logic or Custom widgets.

    For the rest .. it can be done, but I never tried it with Thematic.

    Chris

    Posted 5 years ago #
  3. good tip chris, its too easy.

    i'm wondering the same thing for content width
    "how to increase the width of the content so that it occupies the empty space left by removing the sidebar?"

    Posted 5 years ago #
  4. Hi Scott,

    will test this tomorrow.

    Removing the sidebar for a certain page and changing the width is pretty easy: How to remove the sidebar from a certain page?.

    Don't know if it'll work with my favorite plugin.

    Chris

    Posted 5 years ago #
  5. sober
    Member

    I am using the powerblog theme and is the procedure same for that also ? . It has got a third widget area called crown .

    Posted 5 years ago #
  6. Hi,

    the current version will support this using Widget Context from Kaspars.

    If you setup the three widgetized areas not to display on a certain page or post you only need the CSS part of my above mentioned post.

    The next Thematic release will provide a basic functionality to solve this without a plugin .. just in case that you don't need all the features of this excellent plugin.

    Chris

    Posted 5 years ago #
  7. davidtruog
    Member

    Hi,

    I got a parse error when I used this:
    function kill_sidebar() {
    if (is_page('1') {
    return FALSE;
    } else {
    return TRUE;
    }
    }
    add_action('thematic_sidebar', 'kill_sidebar');

    The parse error was on the 'if' line. So I tried this instead:
    function kill_sidebar() {
    return FALSE;
    }
    add_action('thematic_sidebar', 'kill_sidebar');

    And it works fine. But there must be some good reason do that is_page test. What is the reason? And what could be causing the parse error?

    David

    Posted 4 years ago #
  8. Hi David,

    this should be: (is_page('1'))

    Chris

    Posted 4 years ago #
  9. davidtruog
    Member

    Chris,

    Thanks for your fast reply. That extra parenthesis eliminated the parse error. But now the sidebar appears on both Pages and Posts, which I guess means the is_page() function is always testing negative, so the else{} clause gets executed and therefore the kill_sidebar() function returns TRUE, causing the sidebar to stay visible. Why would is_page() be always testing negative?

    David

    Posted 4 years ago #
  10. Using (is_page('1')) prevents the sidebar only on the page with the ID 1.

    If you want to remove the sidebar from all pages, you need to use (is_page()).

    Posted 4 years ago #
  11. davidtruog
    Member

    Chris,

    Aha -- that worked perfectly. Thank you.

    Now that you've pointed out that it had to do with the argument to that function, I realize I should have searched for a WP function reference page. I just found one in the Codex and I could have answered my own question if I had looked at <http://codex.wordpress.org/Function_Reference/is_page>!

    BTW, It would be great if you were able to correct the unbalanced parentheses in the if clause in the code in the opening post to this thread, so others don't run into the same problem I did as a result of copying what alx43 typed and pasting it directly into functions.php without checking that the parentheses are balanced. Don't know whether it's possible for you to edit posts from that long ago, but I thought I'd mention it in the hope of saving you and others a few minutes next time someone like me finds this thread.

    Thanks again for your help.

    David

    Posted 4 years ago #
  12. Done :)

    Posted 4 years ago #
  13. Where do I place this code to remove the sidebar? Thanks!
    -D

    Posted 3 years ago #
  14. @brcguy - all PHP code for your child theme goes in your child's functions.php

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.