ThemeShaper Forums » Thematic

[sticky] [closed]

Something new 'bout widgetized areas

(70 posts)
  • Started 4 years ago by Chris
  • Latest reply from candregg
  • This topic is not a support question
  1. @mary - maren's code looks mostly right. maybe the conditionals are off. i'd use her code and amend the bottom functions to

    function child_1st_subsidiary_aside {
    if (is_active_sidebar('primary-aside') && is_home()) {
    echo thematic_before_widget_area('primary-aside');
    dynamic_sidebar('primary-aside');
    echo thematic_after_widget_area('primary-aside');
    }
    }
    
    function child_2nd_subsidiary_aside {
    if (is_active_sidebar('secondary-aside') && !is_home()) {
    echo thematic_before_widget_area('secondary-aside');
    dynamic_sidebar('secondary-aside');
    echo thematic_after_widget_area('secondary-aside');
    }
    }

    check the codex for info on WP conditionals
    http://codex.wordpress.org/Conditional_Tags

    Posted 3 years ago #
  2. I am currently working on a site which needs a widget in the header, thanks for this post, saved me sleepless nights...

    Posted 2 years ago #
  3. yitwail
    Member

    Chris,

    In your example for conditional widget display

    function childtheme_secondary_aside() {
    if (is_page()) {
    if (is_sidebar_active('secondary-aside')) {
    echo thematic_before_widget_area('secondary-aside');
    dynamic_sidebar('secondary-aside');
    echo thematic_after_widget_area('secondary-aside');
    }
    }
    }

    can the 2 echos & dynamic sidebar be replaced with this one line?

    thematic_secondary_aside();

    Posted 2 years ago #
  4. boxcar
    Member

    I, too, am trying to have Primary sidebar appear only on blog pages and the Secondary sidebar appear only on pages. I tried @dk's code (above) with corrections suggested by @st3vi3. The secondary sidebar is now appearing on pages only but the primary sidebar is not showing on blog. Here is what I am using:

    // Display Secondary Sidebar only on pages

    function childtheme_secondary_aside() {
    if (is_page()) {
    if (is_sidebar_active('secondary-aside')) {
    echo thematic_before_widget_area('secondary-aside');
    dynamic_sidebar('secondary-aside');
    echo thematic_after_widget_area('secondary-aside');
    }
    }
    }

    function change_secondary_aside($content) {
    $content['Secondary Aside']['function'] = 'childtheme_secondary_aside';
    return $content;
    }
    add_filter('thematic_widgetized_areas','change_secondary_aside');

    // Display Primary Sidebar only on blog pages

    function childtheme_primary_aside() {
    if (is_archive() || is_single()) {
    if (is_sidebar_active('primary-aside')) {
    echo thematic_before_widget_area('primary-aside');
    dynamic_sidebar('primary-aside');
    echo thematic_after_widget_area('primary-aside');
    }
    }
    }

    function change_primary_aside($content) {
    $content['Primary Aside']['function'] = 'childtheme_primary_aside';
    return $content;
    }
    add_filter('thematic_widgetized_areas','change_primary_aside');

    //END

    Can anyone help?
    Thanks!

    Posted 2 years ago #
  5. @boxcar - try changing

    if (is_archive() || is_single()) {

    to

    if (is_archive() || is_single() || is_home()) {

    is_home() is the conditional tag for the blog index

    btw- i'm fairly certain you don't need nested if statements. i think this should work too (i may have borked the num of parens.... no guarantees)

    if ( is_sidebar_active('primary-aside') && (is_archive() || is_single() || is_home()) ) {
    Posted 2 years ago #
  6. boxcar
    Member

    Thanks Helga. That worked! I used the second, compact version. The whole thing that now works follows:

    // This is to Display Secondary Sidebar only on pages
    // and Display Primary Sidebar only on blog pages

    // Display Secondary Sidebar only on pages

    function childtheme_secondary_aside() {
    if (is_page()) {
    if (is_sidebar_active('secondary-aside')) {
    echo thematic_before_widget_area('secondary-aside');
    dynamic_sidebar('secondary-aside');
    echo thematic_after_widget_area('secondary-aside');
    }
    }
    }

    function change_secondary_aside($content) {
    $content['Secondary Aside']['function'] = 'childtheme_secondary_aside';
    return $content;
    }
    add_filter('thematic_widgetized_areas','change_secondary_aside');

    // Display Primary Sidebar only on blog pages

    function childtheme_primary_aside() {
    if ( is_sidebar_active('primary-aside') && (is_archive() || is_single() || is_home()) ) {
    echo thematic_before_widget_area('primary-aside');
    dynamic_sidebar('primary-aside');
    echo thematic_after_widget_area('primary-aside');

    }
    }

    function change_primary_aside($content) {
    $content['Primary Aside']['function'] = 'childtheme_primary_aside';
    return $content;
    }
    add_filter('thematic_widgetized_areas','change_primary_aside');

    // END

    Thank you so much!

    On to the next mountain.

    Posted 2 years ago #
  7. seedling
    Member

    Thank you so much for the easy copy and paste to add a widget to the header. I'm VERY new to php but I tried to manipulate the code so that I can put a widget on to the right side of the LEADER as well.

    I'm using the FEATURE SITE child theme and looking for a widget to place onto the leader of all the pages (and posts) except the home page.

    I've read countless posts about creating widgets but I can't seem to get it to work. Could someone explain (or point me to an explanation) of what code needs to change to create a new widget in a new section of the site.

    This is the site I'm working on - http://alexiavernon.dreamhosters.com/?page_id=6

    Posted 2 years ago #
  8. Greetings. I have a client who wants the Primary widget area to be able to display completely different content based on different categories (and children). Hence the admin area is going to have to include at least six DIFFERENT new widget areas to handle the content, and also six different conditionals to handle the sidebar display.

    I've been trying to figure out the conditional syntax from this thread's previous posts, but I get stopped at the problem of different specific categories.

    I know this is vague, but I'm a little stumped. Any help or direction would be appreciated.

    Posted 1 year ago #
  9. please make a new thread for this sort of thing. it'll be easier for other people to find in the future should they be doing the same thing. but nothing is really different except for the condition:

    create a sidebar with id = "bacon-category" per the instructions/samples in this thread and adjust the callback function's conditionals to check for category

    if (is_active_sidebar('bacon-category') && is_category('bacon')) {
    Posted 1 year ago #
  10. Thanks Helga. I will move this to a new thread, since I remain confused about how the several widget areas will generate in the admin area. Will try some things and see how they go and then continue the discussion later if the problems persist.

    Posted 1 year ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.