Community Forums › Forums › Archived Forums › Design Tips and Tricks › Trouble removing sidebar on Custom Template
Tagged: remove_action, Sidebar
- This topic has 4 replies, 2 voices, and was last updated 9 years, 1 month ago by
juiceman.
-
AuthorPosts
-
January 7, 2016 at 11:04 am #175864
juiceman
ParticipantI'm having trouble removing the primary sidebar from my template. I will include to whole template file in case I'm missing something, but everything is working except the
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
The new sidebar comes in fine, I just can't get rid of the primary one. Am I missing something simple!?
Any help is greatly appreciated!
Here is the Full template:
http://blog.sweet-seed.com/birds/<?php // Template Name: Archive Bird Posts remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); add_action( 'genesis_sidebar', 'child_do_sidebar' ); function child_do_sidebar() { if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'Bird Directory' ) ) { }} add_action('genesis_entry_content', 'ssbd_arc_list', 1); function ssbd_arc_list() { ?> <div class="content entry"> <header class="entry-header"></header> <div class="entry-content"> <div class="one-half first"> <?php genesis_image(); ?> </div> <div class="one-half"> <?php genesis_do_post_title(); ?> <div style="margin-bottom: 20px;"><strong>Filed Under:</strong> <?php the_terms( $post->ID, 'ssbd_birdtypes', '', ', ', ' ' ); ?> • <?php the_terms( $post->ID, 'ssbd_regions', '', ', ', ' ' ); ?></div> <?php genesis_do_post_content(); ?> </div> <div style="clear:both;"></div> </div> </div> <?php } remove_action('genesis_loop', 'genesis_do_loop'); add_action('genesis_loop', 'ssbd_birdtype_loop'); function ssbd_birdtype_loop() { $blackbirdargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'blackbirds' ) ) ); $blackbird_query = new WP_Query( $blackbirdargs ); $bluebirdargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'bluebirds' ) ) ); $buntingargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'buntings' ) ) ); $bushtitargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'bushtits' ) ) ); $cardinalargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'cardinals' ) ) ); $chickadeeargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'chickadees' ) ) ); $creeperargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'creepers' ) ) ); $crossbillargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'crossbills' ) ) ); $finchargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'finches' ) ) ); $grosbeakargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'grosbeaks' ) ) ); $hummingbirdargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'hummingbirds' ) ) ); $jayargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'jays' ) ) ); $kingletargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'kinglets' ) ) ); $mockingbirdargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'mockingbirds' ) ) ); $nuthatchargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'nuthatches' ) ) ); $orioleargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'orioles' ) ) ); $pigeonargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'pigeons' ) ) ); $sparrowargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'sparrows' ) ) ); $starlingargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'starlings' ) ) ); $tanagerargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'tanagers' ) ) ); $thrushargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'thrushes' ) ) ); $titmiceargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'titmice' ) ) ); $towheeargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'towhees' ) ) ); $vireoargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'vireos' ) ) ); $warblerargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'warblers' ) ) ); $waxwingargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'waxwings' ) ) ); $woodpeckerargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'woodpeckers' ) ) ); $wrenargs = array( 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'ssbd_birds', 'tax_query' => array( array( 'taxonomy' => 'ssbd_birdtypes', 'field' => 'slug', 'terms' => 'wrens' ) ) ); // The Query if ( have_posts() ) : ?> <h2>*Blackbirds</h2> <?php while ( $blackbird_query->have_posts() ) : $blackbird_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Bluebirds</h2> <?php $bluebird_query = new WP_Query( $bluebirdargs ); while ( $bluebird_query->have_posts() ) : $bluebird_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Buntings</h2> <?php $bunting_query = new WP_Query( $buntingargs ); while ( $bunting_query->have_posts() ) : $bunting_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Bushtits</h2> <?php $bushtit_query = new WP_Query( $bushtitargs ); while ( $bushtit_query->have_posts() ) : $bushtit_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Cardinals</h2> <?php $cardinal_query = new WP_Query( $cardinalargs ); while ( $cardinal_query->have_posts() ) : $cardinal_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Chickadees</h2> <?php $chickadee_query = new WP_Query( $chickadeeargs ); while ( $chickadee_query->have_posts() ) : $chickadee_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Creepers</h2> <?php $creeper_query = new WP_Query( $creeperargs ); while ( $creeper_query->have_posts() ) : $creeper_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Crossbills</h2> <?php $crossbill_query = new WP_Query( $crossbillargs ); while ( $crossbill_query->have_posts() ) : $crossbill_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Finches</h2> <?php $finch_query = new WP_Query( $finchargs ); while ( $finch_query->have_posts() ) : $finch_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Grosbeaks</h2> <?php $grosbeak_query = new WP_Query( $grosbeakargs ); while ( $grosbeak_query->have_posts() ) : $grosbeak_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Hummingbirds</h2> <?php $hummingbird_query = new WP_Query( $hummingbirdargs ); while ( $hummingbird_query->have_posts() ) : $hummingbird_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Jays</h2> <?php $jay_query = new WP_Query( $jayargs ); while ( $jay_query->have_posts() ) : $jay_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Kinglets</h2> <?php $kinglet_query = new WP_Query( $kingletargs ); while ( $kinglet_query->have_posts() ) : $kinglet_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Mockingbirds</h2> <?php $mockingbird_query = new WP_Query( $mockingbirdargs ); while ( $mockingbird_query->have_posts() ) : $mockingbird_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Nuthatches</h2> <?php $nuthatch_query = new WP_Query( $nuthatchargs ); while ( $nuthatch_query->have_posts() ) : $nuthatch_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Orioles</h2> <?php $oriole_query = new WP_Query( $orioleargs ); while ( $oriole_query->have_posts() ) : $oriole_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Pigeons</h2> <?php $pigeon_query = new WP_Query( $pigeonargs ); while ( $pigeon_query->have_posts() ) : $pigeon_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Sparrows</h2> <?php $sparrow_query = new WP_Query( $sparrowargs ); while ( $sparrow_query->have_posts() ) : $sparrow_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Starlings</h2> <?php $starling_query = new WP_Query( $starlingargs ); while ( $starling_query->have_posts() ) : $starling_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Tanagers</h2> <?php $tanager_query = new WP_Query( $tanagerargs ); while ( $tanager_query->have_posts() ) : $tanager_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Thrushes</h2> <?php $thrush_query = new WP_Query( $thrushargs ); while ( $thrush_query->have_posts() ) : $thrush_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Titmice</h2> <?php $titmice_query = new WP_Query( $titmiceargs ); while ( $titmice_query->have_posts() ) : $titmice_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Towhees</h2> <?php $towhee_query = new WP_Query( $towheeargs ); while ( $towhee_query->have_posts() ) : $towhee_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Vieros</h2> <?php $vireo_query = new WP_Query( $vireoargs ); while ( $vireo_query->have_posts() ) : $vireo_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Warblers</h2> <?php $warbler_query = new WP_Query( $warblerargs ); while ( $warbler_query->have_posts() ) : $warbler_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Waxwings</h2> <?php $waxwing_query = new WP_Query( $waxwingargs ); while ( $waxwing_query->have_posts() ) : $waxwing_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Woodpeckers</h2> <?php $woodpecker_query = new WP_Query( $woodpeckerargs ); while ( $woodpecker_query->have_posts() ) : $woodpecker_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <h2>Wrens</h2> <?php $wren_query = new WP_Query( $wrenargs ); while ( $wren_query->have_posts() ) : $wren_query->the_post(); ssbd_arc_list(); ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php else: ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?> <?php } genesis();
January 8, 2016 at 12:17 am #175911Brad Dalton
ParticipantAdd this:
//* Force full width content layout add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' );
January 8, 2016 at 6:54 am #175947juiceman
Participant@braddalton, thank you for the response. I should have been more clear. I should have titled this post Trouble Replacing... not removing...
This is an archive template. And I need to use a different sidebar. I'm using Genesis simple sidebars. So I just need to get rid of the default primary sidebar and put the new on in it's place.
The code I am using brings in the new sidebar (if you view the page, it's the light gray "New Sidebar" on top of the search box.)
The code is not getting rid of the default sidebar (which is everything under that light gray box ...starting with the search box widget.)Page is here: Page
This is the current code. Full template is above.
add_action( 'genesis_sidebar', 'child_do_sidebar' ); function child_do_sidebar() { if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar( 'Bird Directory' ) ) { }}
Thanks again for taking the time.
January 8, 2016 at 7:02 am #175948Brad Dalton
ParticipantJanuary 8, 2016 at 7:42 am #175951juiceman
ParticipantThis got me the solution I needed:
https://wordpress.org/support/topic/removing-sidebars-doesnt-work-in-code
My template now has this:
remove_action( 'get_header', 'ss_sidebars_init' ); remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); add_action( 'genesis_sidebar', 'bird_directory_sidebar' ); function bird_directory_sidebar() { dynamic_sidebar( 'bird-directory' ); }
This removes the default side bar and replaces it with one that I created using the Genesis Simple Sidebars Plugin.
Thanks again
-
AuthorPosts
- The topic ‘Trouble removing sidebar on Custom Template’ is closed to new replies.