ThemeShaper Forums » Thematic

[closed]

Remove subsidiary based on page

(8 posts)
  • Started 4 years ago by beanfair
  • Latest reply from beanfair
  • This topic is not resolved
  1. beanfair
    Member

    This should be easy but I can't seem to figure out the best way to display the subsidiary only on the front page. I could hard code the if statement in the footer but that would just be bad practice.

    My best guess is to use thematic_footer()but I am having difficulties. Any assistance is welcomed and appreciated.

    Posted 4 years ago #
  2. bhomatude
    Member

    A very easy method is to use this plugin:

    http://wordpress.org/extend/plugins/widget-context/

    Or create a stylesheet just for the home page (with the subsidiary styled with a "display:none" and drop this into your functions.php:

    //Conditional stylesheet for home page

    function home_css() {
    if (is_page('home')) {?>
    <link rel="stylesheet" type="text/css" href="<?php echo
    bloginfo('stylesheet_directory') ?>/homepage.css" /> <?php }
    }
    add_action('wp_head', 'home_css');

    //End Conditional stylesheet for home page

    Posted 4 years ago #
  3. beanfair
    Member

    Unfortunately I can't get that to work either. It is never adding the home page stylesheet.
    I tried to create a new style rule in the default.css file using the home class to style the subsidiary and setting the basic subsidiary class to display: none for all of the other pages but that isn't working either. It still shows the subsidiary on all pages.

    I am really confused to why this is so difficult, I wish we could just comment out the subsidiary on template pages like we can the side bar widgets.

    Any other suggestions? I really wish I could get the conditional style sheet to work. The home page is the only one with the subsidiary and it has different layout dimensions from all of the other templates so I wish I could load one style sheet for that page and in all other cases load the default.css

    Posted 3 years ago #
  4. Creating styles in default.css really defeats the purpose of a child theme, you should be making changes to your child style.css

    There is a dynamic body class for every page generated, so you could create a css rule for that specific class with display none.

    body.home

    and then target the specific div you wish to hide, which I believe is subsidiary in your case, with

    display: none;

    Posted 3 years ago #
  5. i second the use of Widget Logic. It is by far the easiest, least-code-involved solution. another option would be to modify the function that displays the sidebars in question so that they have an extra condition.

    this first function points the widget area to your new function:

    function change_widgetized_area($content) {
    	$content['1st Subsidiary Aside']['function']='child_1st_subsidiary_aside';
    	return $content;
    }
    add_filter('thematic_widgetized_areas', 'change_widgetized_area');

    this function is basically the same as thematic_1st_subsidiary_aside() (found in widget-extensions.php) but with an extra condition for is_home():

    // Re-Define the 1st Subsidiary Aside
    function child_1st_subsidiary_aside() {
    	if (is_active_sidebar('1st-subsidiary-aside') AND is_home() ) {
    		echo thematic_before_widget_area('1st-subsidiary-aside');
    		dynamic_sidebar('1st-subsidiary-aside');
    		echo thematic_after_widget_area('1st-subsidiary-aside');
    	}
    }
    Posted 3 years ago #
  6. beanfair
    Member

    I should clarify that I copied the default.css to my child theme and made the changes there. With that in mind these rules set in my child theme:

    #subsidiary.home {
        width: 90%;
    	padding:20px 20px 0 20px;
    background: #d6c0a2; /*taupe */
    color: #4e2f0a;
    }
    
    #subsidiary {
       display:none;
    }

    results in the subsidiary being shown on every page :-(

    Time to try the widget function solution

    Posted 3 years ago #
  7. i'm not a fan of hiding things w/ CSS, but you are doing it wrong as the subsidiary div doesn't have dynamic classes. it is the BODY that has dynamic tags so this would be the proper order

    #subsidiary { display: none; width: 90%; padding:20px 20px 0 20px; background: #d6c0a2; /*taupe */ color: #4e2f0a;
    }
    
    .home #subsidiary {display: block;}
    Posted 3 years ago #
  8. beanfair
    Member

    @helgatheviking I agree the function is the way to go. Utilizing your code, I can remove the 1st subsidiary aside from the internal pages if I test for my frontpage template.
    Right now I am working on rewriting the first function to control all three subsidiary asides.
    Thank you for your assistance.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.