2

i'm using 3 widget areas in my child theme's footer.

i created a secondary custom theme successfully, and am hoping i can simply change those 3 widget area's out in the second theme.

"Footer - Column 1" would change to "Alt Footer - Column 1"
"Footer - Column 2" would change to "Alt Footer - Column 2"
"Footer - Column 3" would change to "Alt Footer - Column 3"

(and yes, i've already created in WP admin > Appearnace > Widgets, those 3 new custom widget areas, & put temp text widgets in them for now).

i'm using this in "functions.php" to change the "Menu"...

add_filter( 'wp_nav_menu_args', 'respect_menu_swap' );
function respect_menu_swap( $args = '' ) 
{
    if(is_page_template('template-respect.php') && $args['menu_id'] == 'avia-menu') 
    {
        $args['menu'] = '16';
    } 
    return $args;
}

...am hoping for something similar to change each of those "widget areas".

i've searched, read, searched, & read a LOT trying to figure this out & just can't seem to grasp what should go in place of the menu terms in that code bit. i really struggle with PHP, so would greatly appreciate specific explanation & code:-)

and, i'm saying "Widget Area" instead of "Widgets" because i realized that "Widgets" are INSIDE the "Widget Areas". i'd like to swap the whole area instead of just the widget so my people can add/remove various widgets in those 3 "areas" in the WP > Appearance > Widgets admin page as needed. it’s my understanding that if i just use the “Widget ID” then when someone changes which widget(s) are in one of those widget areas, it won’t update on the sites front-end without me changing those ID’s first. i’d like to avoid having to do that if possible.

(BTW: i'm using the Enfold WP theme, if that matters)

1 Answer 1

1

WOW! well, it would seems as tho i figured it out!

after MORE searching, i came across https://learn.wordpress.org/lesson-plan/widget-areas

apparently i had to "register" a "sidebar" - which thru me, as i was wanting to modify in the footer. after looking that up, the term "sidebar" is used anywhere the theme allows the user to add widgets in. and since the Enfold theme footer allows for widgets, i had to "register_sidebar" and THEN modify a line in the template. i also didn't understand why i had to "register" the "widget area's" at all, thinking that just by creating the custom widgets in WP admin > Appearance > Widgets, that should do it, but no. ya gotta create them there and ALSO register them in the child functions too.

so after reading that wordpress page (linked above), i started hunting around in the main Enfold theme files, trying to find something similar. since apparently, some things are named differently than in other themes, which is why my copy/pasting of examples i found elsewhere didn't work. i found it in... themes > enfold > includes > admin > register-widget-area.php

so i combined what that wordpress link offered with the footer widget registration and came up with this code that i put in my child functions.php...

add_action( 'widgets_init', 'MYWIDGETAREA' );
function MYWIDGETAREA() 
{
    register_sidebar( array(
        'name'          => 'Respect Footer - Column ' . $i,
        'id'            => 'espect_foot_widget_' . $i,
        'before_widget' => '<section id="%1$s" class="widget clearfix %2$s">',
        'after_widget'  => '<span class="seperator extralight-border"></span></section>',
        'before_title'  => '<h3 class="widgettitle">',
        'after_title'   => '</h3>'
    ));
}

in the array, i only changed the "name" & "id", leaving the rest so the structure matches the original theme.

then i went to my template-custom.php and found this line...

if( ! ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( 'Footer - Column ' . $i ) ) )

...and replaced it with...

if( ! ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( 'Respect Footer - Column ' . $i ) ) )

AMAZING!!!

well hopefully all this may benefit someone else in a similar position some day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.