one way to accomplish your goal would be to create a child theme (https://codex.wordpress.org/Child_Themes). You create a folder inside /wp-content/themes/
, then add a style.css
file inside it with a few comment lines at the top to tell WordPress this is a child theme of whatever your current theme is.
Sample style.css
file: all you need to do is change parent-theme-folder-name
to whatever your original theme folder is. So for example if you are currently using Twenty Sixteen, change parent-theme-folder-name
below to twenty-sixteen
.
/*
Theme Name: Custom category sidebars
Version: 1.0
Template: parent-theme-folder-name
*/
Next, to create your new sidebars, create a blank functions.php
inside your child theme folder, and add:
<?php
/**
* Add custom sidebars for categories
*/
// Agenda Category Sidebar
register_sidebar(array(
'name' => 'Agenda sidebar',
'id' => 'agenda-sidebar',
'description' => 'Agenda category sidebar'
));
// Articulos Category Sidebar
register_sidebar(array(
'name' => 'Articulos sidebar',
'id' => 'articulos-sidebar',
'description' => 'Articulos category sidebar'
));
Finally, create a blank category-agenda.php
file and a blank category-articulos.php
file. Copy and paste your original theme’s category.php
code right into those files. Then, look for the sidebar portion, and change the part where it calls the sidebar:
Again in this example just change sidebar-slug
to your new slug: in category-agenda.php
change it to agenda-sidebar
, and in category-articulos.php
change it to articulos-sidebar
.
Once all these files are created and uploaded, activate your child theme and set up the widgets in the sidebars however you like.