Community Forums › Forums › Archived Forums › General Discussion › Custom Sidebars for CPT Showing Primary Widgets as Well
Tagged: CPT, Genesis Simple Sidebars, sidebars, widgets
- This topic has 6 replies, 4 voices, and was last updated 11 years, 11 months ago by
weslinda.
-
AuthorPosts
-
March 26, 2013 at 10:36 am #31337
weslinda
MemberI'm using the Sermon Manager plugin by WordPress Churches for a client build. The plugin sets up everything under a CPT. Nice and clean. I'm replacing the standard sidebar with a custom one, and running into a problem. Both the widgets in the Primary Sidebar AND my custom sidebar are showing on the page. In one sidebar. I'm quite confused by what's causing this. Below is the code I'm using to call the custom sidebar.
// Add Sermon Sidebar to Sermons Page
add_action('get_header','uptown_change_genesis_sidebar');
function uptown_change_genesis_sidebar() {
if ( 'wpfc_sermon' == get_post_type() ) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'sermons_do_sidebar' );
}
}//Function to output my custom sidebar
function sermons_do_sidebar() {
genesis_widget_area( 'sermon-downloads-sidebar' );
}
Loving the Genesis Life!
March 26, 2013 at 11:14 am #31343David Chu
ParticipantHi!
I have one lead for you. If you're running Genesis Simple Sidebars, that will kill any custom remove_action or add_action sidebar activities. I scratched my head for awhile before figuring this out. Genesis Simple Sidebars is an awesome plugin, but one can have one or the other, not both.If that's not it, you could display get_post_type and see if that's coming through.
Dave
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
March 26, 2013 at 11:19 am #31344weslinda
MemberDave, thanks for the reply, but it's taking the request to change the sidebar, it's just combining the custom one with the standard one. That's where the confusion lies. I am using Genesis Simple Sidebars, but this change is required to affect the sidebar on the archives of a CPT from a plugin.
Loving the Genesis Life!
March 26, 2013 at 11:27 am #31346surefirewebserv
MemberWhat happens if you remove the code from your functions file? I think the simple sidebars plugin would suffice without the extra code in functions.php.
SureFireWebServices.com | Genesis Tuts and More
Genesis Theme Starter Kit | It’s FreeMarch 26, 2013 at 11:28 am #31347billerickson
MemberTwo issues:
You need to remove the function that Genesis Simple Sidebars adds to create a sidebar. That's what's causing the extra one
You should make your function hook in later so that it will catch Genesis Simple SidebarsHere's how I would do it: https://gist.github.com/billerickson/5247346
You could also simplify this by replacing the last add_action() with the dynamic_sidebar( 'sermon-sidebar' ) since you're already on the genesis_sidebar hook.
March 26, 2013 at 11:31 am #31350David Chu
ParticipantI'm with ya. 🙂 And I could be wrong, because I'm not in the guts of your code, but if I'm understanding you, it's actually doing just what I said: the following bit of code won't work (because of Genesis Simple Sidebars killing it), so it leaves the regular widget there; Primary Sidebar will stay! That's my best guess based on experience, and based on what little info I have here.
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
Hope that gets you a bit further! Good luck,
Dave
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
March 26, 2013 at 11:48 am #31355weslinda
MemberBill,
Thanks that did the trick. Interesting that it's pulling widgets from both the primary sidebar and the custom one i've defined. This is pretty interesting that it's doing this. I like the Simple Sidebars as it gives complete flexibility to the client, but little stuff like this makes it challenging to implement in a clean manner.
This gets me through the primary issue and puts a piece of knowledge out there that I wasn't aware of.
Flamenco, your original point was that it was killing my code, which it wasn't fully. It was pulling in the sidebar widgets I wanted, but was combining it with the default sidebar widgets. That's what was throwing me. If it wasn't working at all, that would have been different. However, it was GSS causing the hiccup. Kinda interesting to say the least. It's weird. Seems like a bug in GSS if it's calling both.
Does anyone know if there is an easy way to tell GSS to default to another sidebar for a custom post type? Maybe there is a hook / filter in GSS that would allow this? I can enable GSS for CPTs with ease, but the issue is the core archive page for these CPTs created by other plugins. There isn't an admin where I can add the sidebar selector to.
Anyone know if that's an option in GSS where I'm not turning it off? Rather I'm able to tell GSS what sidebar to use for a CPT in my functions file.
Loving the Genesis Life!
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.