I’m trying to figure out how to load an alternative sidebar in a WordPress theme I’m creating (I’m a novice, by the way). A very old answer on stackoverflow suggests creating a new sidebar and calling it something like sidebar_alt.php and altering the code as follows:
<?php get_sidebar('alt'); ?>
But that doesn’t work for me, it just keeps loading the original sidebar. I read a different answer that said you have to register the alternative sidebar in the functions.php file. Do any of you very nice, smart and helpful people out there know if this is true? If so, what code would I have to add? Or is there another alternative (that doesn’t include plugins)?
Many thanks in advance.
https://codex.wordpress.org/Function_Reference/get_sidebar
You have created sidebar file with name “sidebar_alt.php” which is wrong you should create it like
"sidebar-{name}.php"
eg. "sidebar-alt.php".