Community Forums › Forums › Archived Forums › Design Tips and Tricks › Code from Carrie Dils (2015 post) to call custom sidebar for specified category
Tagged: Genesis Simple Sidebars, Outreach Pro
- This topic has 3 replies, 2 voices, and was last updated 7 years, 5 months ago by
wildwebwest.
-
AuthorPosts
-
November 1, 2017 at 8:21 pm #213162
wildwebwest
MemberHi Genesis Fans:
I'm upgrading a municipal site to a mobile responsive theme - using outreach-pro.
Here's my question... the staging site is at idahocounty.com
Way back in 2010, I started this client on using posts for minutes and agendas to organize things easily so there are currently 7 years of posts.
[Unless you know of an easier way to bulk update lots of single posts so that they reflect the appropriate left sidebar for the category the post belongs to...]
I would like to be able to setup some custom code in the functions.php file so that no one has to go in and update every single post so that it reflects the specific left custom sidebar that fits with the specific category. It would happen automatically in the single posts. The right primary sidebar always uses the default so no need to deal with that one.
Does this code from Carrie Dils still work in modern Genesis framework (many upgrades since the help blog was posted)? Obviously I would edit to match the categories that I've setup. I just want to avoid opening every single post to assign a custom left sidebar and hope this code might do the trick for the various categories (mostly minutes and agendas).
I am using Genesis Simple Sidebars - one of my faves - to create multiple sidebars as we web developers always want to accommodate the clients preferences, of course!
Here's the code:
---------------------
add_action('get_header','cd_change_genesis_sidebar');
function cd_change_genesis_sidebar() {
if ( is_singular('jobs')) { // Check if we're on a single post for my CPT called "jobs"
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
add_action( 'genesis_sidebar', 'cd_do_sidebar' ); //add an action hook to call the function for my custom sidebar
}
}//Function to output my custom sidebar
function cd_do_sidebar() {
dynamic_sidebar( 'job-single-sidebar' );
}-------------
Thanks for any advice. I'm not a real strong coder but I've been muddling through over the years by finding sharp people like Carrie who make things easy.
Wild Web West, LLC
#IHeartGenesisNovember 3, 2017 at 7:15 am #213215Victor Font
ModeratorIt looks like it should still work. Did you try it or ask Carrie?
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?November 5, 2017 at 6:50 pm #213301wildwebwest
MemberHi Victor. Thank you for your reply.
No, I didn't ask Carrie. I was kind of looking for concrete answers from experts like you from end of 2017 since this code was created almost 2.5 years ago. So much has changed. I'll go for it and will leave this open until I test it out.
I may still need help (I'm a weak coder) because I'm using Genesis Simple Sidebars to build custom left sidebars which throws an extra wrench in the spokes in terms of challenges. I'll leave this open and if I need help or I am successful, I'll post back.
Thanks again Victor.
Wild Web West, LLC
#IHeartGenesisNovember 10, 2017 at 11:00 pm #213472wildwebwest
MemberWe can close this ticket. Its just too complicated for me and no time to waste.
Wild Web West, LLC
#IHeartGenesis -
AuthorPosts
- The topic ‘Code from Carrie Dils (2015 post) to call custom sidebar for specified category’ is closed to new replies.