Tag Info

New answers tagged

0

I have figured this out. The trick is to use the get_sidebar hook and run some conditionals to check if we're on a CPT page (archive or singular or cpt taxonomy archive) and if the sidebar we've hooked into is the one we want to replace ($sidebar == 'content'). If these conditionals are met we unregister sidebar-2 and add our own sidebar. This probably ...


0

I wouldn't use unregister_sidebar I would copy over the sidebar-content.php file to a plugin and add conditionals to the default sidebar-2 as well as add a new sidebar-4 in that file with the conditional for it. <?php if( is_active_sidebar( 'sidebar-4' ) && is_singular('your-cpt') ) { } ?> <div id="content-sidebar" class="content-sidebar ...


0

the best option here if you want to use a plugin is to use the woo sidebars plugin which is from from woo themes, its also packaged in their free plugin woo dojo which has several free plugins, if your good with options framework by devin or smof and don't mind using cmb meta boxes by jaredatch then i have a github gist that will allow you to select the ...


1

Install metabox plugin and active: /**** Add this code in your function.php ****/ $meta_boxes[] = array( 'id' => 'post_sidebar', 'title' => 'post Sidebar', 'pages' => array('post'), 'priority' => 'low', 'fields' => array( array( 'name' => 'Post ...


0

Your code seems a little superfluous; I'm pretty sure you could compact it to simply: <?php do_action( 'before_sidebar' ); if ( ! $sidebar = get_post_meta( get_the_ID(), '_cmb_test_select', true ) ) $sidebar = 'sidebar-1'; // Default sidebar if meta value does not exist. if ( ! dynamic_sidebar( $sidebar ) ) : ?> <!-- No widgets for ...


0

Well, the very obvious way to shorten it is to simply avoid repeating yourself: ?> <div class="large-3 medium-3 columns"> <div class="panel"><?php if ( is_active_sidebar( 'available-course-list-1' ) ) { dynamic_sidebar( 'available-course-list-1' ); } else { ?> <h5>Available Course List #2</h5> ...


2

is_active_sidebar has a single value, whether it is the sideabar id or name. If you have more than one sidebar, you should repeat is_active_sidebar, each one with a specific sidebar id or name. You would do something like this <?php if ( is_active_sidebar( 'available-course-list-1' ) && is_active_sidebar( 'available-course-list-2' )) : ?>


3

There actually are filters coming with WP 3.9+: do_action( 'dynamic_sidebar_before', $index, false ); do_action( 'dynamic_sidebar_after', $index, false ); apply_filters( 'dynamic_sidebar_has_widgets', false, $index ); The 2nd argument indicates if the sidebar has widgets. Current workaround: Hook into sanitize_title() as this will hold the current ...


0

I've used load_template to call for sidebar template: load_template ( dirname( __FILE__ ) . '/sidebar-mytype.php' ) ;



Top 50 recent answers are included