Community Forums › Forums › Archived Forums › General Discussion › Different Sidebar on a CPT Archive Index Page
Tagged: simple sidebars
- This topic has 5 replies, 3 voices, and was last updated 12 years ago by Jen Baumann.
-
AuthorPosts
-
December 21, 2012 at 3:11 pm #6743Lucas HallMember
How do I remove the primary sidebar from (and add another created by Genesis Simple Sidebars) a Custom Post Type Archive page?
I've created a CPT with a "'has_archive' => true,". That page can be found here: http://landlordology.com/tips/, which is being created by a template called "archive-tips.php"
When I try to remove the primary sidebar, and replace it with one created by the Genesis Simple Sidebar Plugin, the primary does not get removed.
The following code isn't working: remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
The result is that my new sidebar (tips-sidebar) is added underneath the current primary sidebar. On the page: http://landlordology.com/tips/, the Facebook like box is the last item in the primary sidebar.
Here is the code I'm using:
/************************************************
New Sidebar for Tips
************************************************/
add_action('get_header','cd_change_genesis_sidebar');
function cd_change_genesis_sidebar() {
if ( is_post_type_archive('tips') ) { // My CPT is called tips
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( 'tips-sidebar' ); // tips-sidebar is a widget area created by the Genesis Simple Sidebar plugin
}This question was partially addressed by Ron but the solution doesn't help the CPT archive/index page:http://www.studiopress.com/support/showthread.php?p=574602
Best,
Lucas Hall
http://Landlordology.comDecember 22, 2012 at 9:42 am #6941Jen BaumannParticipantWhen you use Simple Sidebars, the actions change. If you open Simple Sidebars and look at the code, you'll see that the standard Genesis sidebar is already removed with the following code.
function ss_sidebars_init() {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
add_action( 'genesis_sidebar', 'ss_do_sidebar' );
add_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
}December 22, 2012 at 1:45 pm #7013cdilsParticipantHi Lucas,
Try creating a regular ole Page and setting it to use your archive-tips.php template. There's a dropdown box on the page where you can select which sidebar you want to use - no extra code needed. 🙂
The code you're referencing above would be if you wanted to specify the sidebar with code alone and no template (archive-tips.php).
Carrie
Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. 🙂
I host a weekly WordPress-focused podcast called Office Hours. I tweet @cdils.
December 22, 2012 at 6:42 pm #7072Jen BaumannParticipantA page template would need a custom CPT loop to work.
http://wpsmith.net/2011/genesis/how-to-create-a-wordpress-custom-post-type-template-in-genesis/December 30, 2012 at 10:30 pm #8524Lucas HallMemberThanks you guys! Excellent support. I simply removed ss_do_sidebar and it worked perfectly.
Best,
Lucas Hall
http://Landlordology.comDecember 31, 2012 at 8:24 am #8591Jen BaumannParticipantGlad to help!
-
AuthorPosts
- The topic ‘Different Sidebar on a CPT Archive Index Page’ is closed to new replies.