How to specify a sidebar for a template

Community Forums Forums Design Tips and Tricks How to specify a sidebar for a template

This topic is: not resolved

This topic contains 12 replies, has 2 voices, and was last updated by  derekalvarez 1 year ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #62868

    derekalvarez
    Participant
    Post count: 47

    How do I specify what sidebar to show for a custom template?

    I created a sidebar called “events” with Genesis Simple Sidebars and only want that to show on my events page. Here is the code I already have on the template file…

    <div id="sidebar" class="sidebar widget-area">
    <?php genesis_sidebar() ?>
    </div>

    I think the code I need to add is something like this, but I’m not sure how to apply it…

    genesis_widget_area( ‘events’, array( ‘before’ => ”, ‘after’ => ”,

    http://test.epicmag.org/events/
    #62873

    braddalton
    Participant
    Post count: 10170

    Simply select it from the meta box on the edit screen of the template.

    You can also add custom post type support for CPT templates for Genesis Simple Sidebars. http://ahjira.com/enable-genesis-simple-sidebars-plugin-for-custom-post-types/


    #62886

    derekalvarez
    Participant
    Post count: 47

    I forgot to mention it’s an Events Calendar plugin template file and I can’t access a page to edit it like that. They automatically create a page link called /events

    #62952

    braddalton
    Participant
    Post count: 10170

    You can change the layout in Genesis conditionally use PHP code in your functions.php file but it looks like that may not work for a template generated by a plugin.

    I would ask the plugin author.


    #62976

    derekalvarez
    Participant
    Post count: 47

    I can change the template file, but the plugin doesn’t create a page for me to select the sidebar. Here is the code I have on the template file…


    <?php
    /**
    * Default Events Template
    * This file is the basic wrapper template for all the views if 'Default Events Template'
    * is selected in Events -> Settings -> Template -> Events Template.
    *
    * Override this template in your own theme by creating a file at [your-theme]/tribe-events/default-template.php
    *
    * @package TribeEventsCalendar
    * @since 3.0
    * @author Modern Tribe Inc.
    *
    */

    if ( !defined('ABSPATH') ) { die('-1'); } ?>

    <?php get_header(); ?>

    <div id="content-sidebar-wrap">

    <div id="content">
    <div id="tribe-events-pg-template">
    <?php tribe_events_before_html(); ?>
    <?php tribe_get_view(); ?>
    <?php tribe_events_after_html(); ?>
    </div> <!-- #tribe-events-pg-template -->
    </div>

    <div id="sidebar" class="sidebar widget-area">
    <?php genesis_sidebar() ?>
    </div>

    </div> <!-- #content-sidebar-wrap -->

    <?php get_footer(); ?>

    I asked the plugin author and he said to check with my theme author.

    #62977

    braddalton
    Participant
    Post count: 10170

    Can you please link to the template.


    #62978

    derekalvarez
    Participant
    Post count: 47

    Did you mean this…
    http://test.epicmag.org/events/

    #62979

    braddalton
    Participant
    Post count: 10170

    An easy way around this may be to use conditional widgets with the page slug for your custom template.

    Widget Logic is a plugin where you can simply add conditional tags to hide or display specific widgets on different pages.
    [php]
    is_page(events) or !is_page(events)
    [/php]

    Hard to test unless i setup everything the same as you have with the plugin installed and same code as you have.


    #63011

    derekalvarez
    Participant
    Post count: 47

    That worked perfect! Thanks, Brad!

    I looked here to see how to do the opposite…
    http://codex.wordpress.org/Conditional_Tags

    I want to take another widget and make sure it doesn’t show on the events page… do you know how to do this? Something like…


    if_page(events): false

    #63014

    braddalton
    Participant
    Post count: 10170

    Try this:

    [php]!is_page(events)[/php]


    #63016

    derekalvarez
    Participant
    Post count: 47

    I tried…


    is_page(events)

    and…


    !is_page(events)

    And it either stops showing it altogether or shows it on every page. Then I tried…


    is_page(events) or !is_page(events)

    And it shows it on every page.

    #63017

    derekalvarez
    Participant
    Post count: 47

    It had worked at first and then stopped, weird.

    #63594

    derekalvarez
    Participant
    Post count: 47

    I found a better plugin (for me)…
    http://wordpress.org/plugins/widget-context/

    This took care of everything. Thanks for setting me on the right track!

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.