StudioPress Community Forums
  StudioPress Community Forums > Forums > General Discussion
For help and support, access to your downloads, or to manage your account please log into My StudioPress.

These forums have been set to read-only so you can browse the existing topics for any questions you may have -- and this forum will be removed on July 1st, 2013.

For general discussion on WordPress, CSS and design (NOT for support) visit the new Community Forums.
 
 
Thread Tools Display Modes
  #1  
Old 09-26-2012, 05:29 PM
jjaycallejas jjaycallejas is offline
Registered User
Pro Plus Member
 
Join Date: Nov 2011
Posts: 154
Default Adding Simple sidebar to template

Hi,

Does anyone know the call for sidebars made with genesis simple sidebars? I'm trying to hook it one onto a custom post type.

Thanks!
  #2  
Old 09-26-2012, 11:15 PM
Bill Murray Bill Murray is offline
Registered User
Pro Plus Member
 
Join Date: Aug 2010
Posts: 645
Default

In the function that registers your CPT, you'd normally have an array of arguments, one of which is 'supports'. The 'support' argument itself can be an array, and to the argument you add 'genesis-simple-sidebars'.

Below is a working example:

PHP Code:
    $args = array(
        
'labels' => $labels,
        
'public' => true,
        
'publicly_queryable' => true,
        
'show_ui' => true,
        
'query_var' => true,
        
'menu_position' => 5,
        
'has_archive' => false,
        
'menu_icon' => get_stylesheet_directory_uri() . '/images/map.png',
        
'rewrite' => array('slug' => 'communities''with_front' => false),
        
'capability_type' => 'post',
        
'hierarchical' => false,
        
'taxonomies' => array('category','post_tag','jmr_property_type','jmr_county','jmr_city','jmr_builders'),
        
'supports' => array('title','editor','thumbnail','author','comments','custom-fields','genesis-seo','genesis-layouts','genesis-simple-sidebars')
      ); 
Hope that helps.
  #3  
Old 09-27-2012, 09:09 AM
jjaycallejas jjaycallejas is offline
Registered User
Pro Plus Member
 
Join Date: Nov 2011
Posts: 154
Default

Wooh! thanks Bill. Definitely works for what I want to accomplish.

A quick question if you don't mind. Ideally, I'd like to write a function replacing the primary sidebar for this post type with one created with simple sidebars. I've done this before with registered sidebars via functions.php, but not sure about how it would be done with simple sidebars.

In the meantime, the solution you provided will work and allows for a lot of flexibility. But I can see where this can be a little tedious if I'd like to assign one sidebar to the entire post type instead of assigning it on every single post. Just trying to cover all bases.

Heres how I've done it before

Code:
remove_action ('genesis_sidebar', 'genesis_do_sidebar');
add_action ('genesis_sidebar', 'about_nav');
function about_nav() {
	if (!dynamic_sidebar('sidebarname'));
}
PHP Code:
genesis_register_sidebar(array(
    
'name'=>'About Navigation',
    
'id' => 'sidebarname',)); 
Another thing, I also notice that when I register sidebars this way, they aren't visible on simple sidebars drowndown selection. Anyone know why?
  #4  
Old 09-27-2012, 09:50 PM
Bill Murray Bill Murray is offline
Registered User
Pro Plus Member
 
Join Date: Aug 2010
Posts: 645
Default

On your first question, it seems like it might work. The code in your functions.php will execute after Simple Sidebars executes, so the sidebars should exist for you to assign a sidebar to a CPT. Give it a try and see how it works out.

On your second question, Simple Sidebars stores the sidebars it creates as records in the options table. It grabs the sidebars created from these options. If you want a sidebar to appear in the pull down list, you'd be better off to fire the code that Simple Sidebars uses to create a sidebar. You could do something conditionally, like check if a Simple Sidebars function exists or the plugin is activated, and if so, call its functions to create the sidebar. Then, they'd exist in the Simple Sidebar options and would appear in the pull down.

You also might get better visibility to post questions like these in the Plugins forum here.
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:33 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.