Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding different sidebar to a template
Tagged: Page Templates, registering sidebar widget, sidebars
- This topic has 3 replies, 3 voices, and was last updated 10 years, 1 month ago by
lcrand.
-
AuthorPosts
-
February 1, 2015 at 2:48 pm #139313
lcrand
MemberI am using the Epik theme from Genesis
http://development.fers-route-to-retirement.com/free-articles/The theme comes with a primary (right) and secondary (left) sidebar but I want to create a template page for a certain section of the site that just has a secondary sidebar.
1. I created a template - page_lessons.php
2. I registered a new sidebar widget in the child functions file using this code:
//* Register lessons sidebar widget area
genesis_register_sidebar( array(
'id' => 'lessons',
'name' => __( 'Lessons Page', 'Epik' ),
'description' => __( 'This is a sidebar widget area for the lessons pages', 'Epik' ),
) );3. I created a new sidebar_lessons.php file and put this in it:
<div id="sidebar" class="sidebar widget-area">
<?php
genesis_structural_wrap( 'sidebar' );
do_action( 'genesis_before_sidebar_widget_area' );
dynamic_sidebar('lessons-sidebar');
do_action( 'genesis_after_sidebar_widget_area' );
genesis_structural_wrap( 'sidebar', 'close' );
?>
</div>4. This is where I think I went wrong:
I added this code to the page_lessons.php file:<?php
// Template Name: Lessons
add_action( 'get_header', 'child_sidebar_logic' );
/**
* Swap in a different sidebar instead of the default sidebar.
**/
function child_sidebar_logic() {
if ( is_page_template( 'page_lessons.php' ) )
{
remove_action( 'genesis_before_sidebar_widget_area', 'genesis_get_sidebar' );
add_action( 'genesis_before_sidebar_widget_area', 'child_get_lessons-sidebar' );
}
{
remove_action( 'genesis_after_content', 'genesis_get_sidebar' )
}
}/**
* Retrieve blog sidebar
*/
function child_get_lessons() {
get_sidebar( 'lessons-sidebar' );
}genesis();
5. On the page I am using to test it, it is still showing the regular secondary sidebar from the original sidebar widget. It did remove the primary sidebar, as I wanted, but the content area is still as narrow as though there is a sidebar there. I get confused about naming conventions with this stuff - is that my problem? Or is there something else wrong?
http://development.fers-route-to-retirement.com/free-articles/February 2, 2015 at 12:08 am #139340WisdmLabs
MemberHi,
You could use a filter to force a layout on the template. Genesis has 6 default layouts.
Refer this link
http://genesissnippets.com/force-a-layout/
February 2, 2015 at 2:04 am #139347Genesis Developer
Membertry the Genesis Simple Sidebar Plugins once.
February 2, 2015 at 6:34 pm #139457lcrand
MemberWisdmLabs-
That worked great for getting the secondary sidebar to show up, but any leads on getting it to call in the new sidebar widget? It's still calling in the main one...
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.