• Resolved leilaChanler

    (@leilachanler)


    I am using the Epik theme from Genesis
    https://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
    //* Hook after post widget area before page content
    genesis_widget_area( 'after-post', array( 'before' => '<div class="after-post widget-area">',
    
    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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you asked StudioPress about this? They’d be the best ones to help you with a commercial theme –

    https://codex.www.ads-software.com/Forum_Welcome#Commercial_Products

    Thread Starter leilaChanler

    (@leilachanler)

    Oops! That line from the page_lessons.php file:

    //* Hook after post widget area before page content
    genesis_widget_area( 'after-post', array( 'before' => '<div class="after-post widget-area">',

    was NOT actually in there. I was playing around before I wrote this post and forgot to remove it. The actual code in that template page is thig:

    <?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();
    Thread Starter leilaChanler

    (@leilachanler)

    Yes, I have. They are just not so responsive. But thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding different sidebar to a template’ is closed to new replies.