ThemeShaper Forums » Thematic

[closed]

Please Tell Me What is Wrong (Conditional Tag, Sidebar, Template)

(7 posts)
  • Started 3 years ago by almour
  • Latest reply from almour
  • This topic is resolved
  1. almour
    Member

    Hi everybody,

    My settings are below:
    I am using WP 3.1 and Thematic 0.9.7.7. I also use custom loops built based on this

    http://hardiannazief.com/12/create-custom-posts-layout-in-home-page-thematic-child-theme/

    I made some minor adjustments and I believe they're irrelevant.

    My problem is:
    I want to make a full width display on Last post page page and Category page. So I decided to get rid of the sidebar, and two options (that I know of) to do this is using a full width template or a function to "kill" the sidebar and make the proper adjustment on CSS (wider body container).

    First I tried using a template, copied full-width.php from thematic and pasted it on my theme child. The file name appeared on my dashboard, but nothing changes, the sidebar is still there. But when I used it for the other pages, it works.

    Since the first option failed, I tried the second one. The code:

    // kill sidebar
    function remove_sidebar(){
    	if (is_category() && is_page('4')){
    		return TRUE; // please notice this part
    	}else{
    		return FALSE; // and this
    	}
    }
    add_filter('thematic_sidebar', 'remove_sidebar');

    First I was using Boolean FALSE and TRUE respectively, but it didn't worked, I googled and found Chris's method (which is the same)

    http://programming.thematic4you.com/2010/01/how-to-remove-the-sidebar-from-a-certain-page/

    but somehow, this isn't work. I switch the Boolean like my above code, and it works.

    What went wrong?

    Anyway, strange as it was, I've resolved it and move on to the next step, making the proper adjustment in CSS. Since I want the CSS specific to a Page and Category, I made a custom CSS file and use conditional function. My code is:

    //full-width CSS for homepage and category
    function fullwidth_css() {
    if (is_page('Articles') && is_category()) {?>
    	<link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_directory') ?>/full-width.css"/>
    	<?php }
    }
    add_action('wp_head', 'fullwidth_css');

    Again, this is not working.

    I have used two of the methods I mentioned here before, using template and conditional CSS style although of course there are minor differences, such as file name and conditions. It worked before but now, it is not.

    Please tell me what is wrong or are there any changes that I am not aware of.

    Thanks in advance!

    Posted 3 years ago #
  2. your conditionals are wacky

    is_page('Articles') && is_category()

    && stands for AND

    so in order for your condition to be true you must be on a category archive AND on a page at the same time... which, to my knowledge, is impossible. thus you will always get a false and your code never activates.

    try using OR (or double pipes || )

    Posted 3 years ago #
  3. almour
    Member

    *slaps head*

    Thank you Helga!

    Well, the is_page() doesn't seem to evaluate so I still get sidebar on the page. You are right though. I'll try another workaround for this issue.

    I'll mark this thread as resolved, but I'd really like to know what's wrong with is_page().

    Posted 3 years ago #
  4. well you have to use the slug... so it is possible that you need to use is_page('articles') in lower case. not 100% sure on that, but worth a try i think.

    Posted 3 years ago #
  5. almour
    Member

    Sorry for the late replies,

    I have tried various ways, with and without: ' ', " ", '4' (the Page ID).. I don't know.. As far as I can tell, it suppose to be working, as I've used this way / codes before. But maybe I missed something, hey, I was using the wrong operator before :P

    Posted 3 years ago #
  6. check your source code. are you sure the stylesheet isn't getting in to the header? or is perhaps the order of the stylesheets wrong.. ie this style sheet comes before the normal sheet and the rules are therefore overridden by what comes later? got a link?

    Posted 3 years ago #
  7. almour
    Member

    Hi Helga,

    Thank you for all of your suggestions and pointers. It works now, but I discovered something weird, possibly bug. I've uploaded the theme to a test site BTW, just in case you are interested:

    http://templatebaru.co.cc/

    Excuse the free domain and very "minimalist" CSS :P.

    It looks like when / if I set the post page to the page I would address the custom CSS, it wont works, but it works when I set post page to another page. So in my reading setting: Front page display: a static page (Select Below) *** Front page: About *** Post Page: First Page. Hope I can make every reader understand..

    ^^^ This will works.

    But: Post Page: Third Page >> Not working on both sidebar and CSS (Sidebar is still there and CSS not getting in wp_head. Third page being a page that I would like to be sidebar-less and full width.

    This is my code:

    //full-width CSS for homepage and category
    // 15 is Third Page's ID
    function fullwidth_css() {
    if (is_page(15) || is_category()){?>
    	<link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_directory') ?>/full-width.css"/>
    	<?php }
    }
    add_action('wp_head', 'fullwidth_css');
    
    // kill sidebar
    function remove_sidebar(){
    	if (is_category() || is_page(15)){
    		return FALSE;
    	}else{
    		return TRUE;
    	}
    }
    add_filter('thematic_sidebar', 'remove_sidebar');

    If anyone wants to take a look then feel free, I will set my post page to Third Page (ID = 15) so it will be on error condition. As for my project, I will try to find a workaround, probably by using page template for a "fake" post page.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.