Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to specify a sidebar for a template
Tagged: custom sidebar, custom template, Goinggreen
- This topic has 12 replies, 2 voices, and was last updated 9 years, 6 months ago by
derekalvarez.
-
AuthorPosts
-
September 16, 2013 at 2:01 pm #62868
derekalvarez
MemberHow 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…
http://test.epicmag.org/events/
genesis_widget_area( ‘events’, array( ‘before’ => ”, ‘after’ => ”,
September 16, 2013 at 2:50 pm #62873Brad Dalton
ParticipantSimply 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/
September 16, 2013 at 3:52 pm #62886derekalvarez
MemberI 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
September 17, 2013 at 2:36 am #62952Brad Dalton
ParticipantYou 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.
September 17, 2013 at 8:06 am #62976derekalvarez
MemberI 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.
September 17, 2013 at 8:29 am #62977Brad Dalton
ParticipantSeptember 17, 2013 at 8:37 am #62978derekalvarez
MemberDid you mean this...
http://test.epicmag.org/events/September 17, 2013 at 8:50 am #62979Brad Dalton
ParticipantAn 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.
is_page(events) or !is_page(events)
Hard to test unless i setup everything the same as you have with the plugin installed and same code as you have.
September 17, 2013 at 11:07 am #63011derekalvarez
MemberThat worked perfect! Thanks, Brad!
I looked here to see how to do the opposite...
http://codex.wordpress.org/Conditional_TagsI 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
September 17, 2013 at 11:18 am #63014Brad Dalton
ParticipantSeptember 17, 2013 at 11:20 am #63016derekalvarez
MemberI 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.
September 17, 2013 at 11:23 am #63017derekalvarez
MemberIt had worked at first and then stopped, weird.
September 20, 2013 at 5:22 pm #63594derekalvarez
MemberI 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!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.