functions – Swap WordPress “Widget Area” based on Page Template

Question

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 Areainstead 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)

0
SyberKnight 2 months 2023-01-29T17:47:48-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse