StudioPress Community Forums

StudioPress Community Forums (http://www.studiopress.com/support/index.php)
-   General Discussion (http://www.studiopress.com/support/forumdisplay.php?f=7)
-   -   Adding Simple sidebar to template (http://www.studiopress.com/support/showthread.php?t=118871)

jjaycallejas 09-26-2012 05:29 PM

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!

Bill Murray 09-26-2012 11:15 PM

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.

jjaycallejas 09-27-2012 09:09 AM

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?

Bill Murray 09-27-2012 09:50 PM

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.


All times are GMT -5. The time now is 10:34 PM.

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