Plugin Directory

Dynamics Sidebars

Add a custom field to add widget area for Pages.

Add a custom options to Pages so Pages can display a different sidebars.

Please Note

  • Requires at least: 3.0
  • Tested up to: 3.2.1

Install

  1. Unzip the dynamics-sidebars.zip file.
  2. Upload the the dynamics-sidebars folder (not just the files in it!) to your wp-contents/plugins folder. If you're using FTP, use 'binary' mode.

Activate

  1. In your WordPress administration, go to the Plugins page
  2. Activate the Dynamics Sidebars plugin.

Usage

  1. After activating the plugin
  2. Go to the Pages > Add or New and you should see the Dynamic Sidebar Metabox on the side (if not showing up try active 'Dynamic Sidebar' under 'Screen Options' on 'Edit Page' page on the top-right handside and make sure 'Dynamic Sidebar' is ticked )
  3. Enter the name of your dynamic sidebar, recommend to put the same name as your page title
  4. Go to the Appearance > Widget page and place anything on your new widget area
  5. On either files page.php, sidebar.php, sidebar-{custom}.php or custom-template.php just add the following code:
<?php
    // Get the current post sidebar area
    $dynamic_sidebar = get_post_meta( $post->ID, 'dynamic_sidebar', true );
    
    // Display the sidebar area
    dynamic_sidebar( $dynamic_sidebar );
?>

Checking if sidebar is active

<?php
    // Get the current post sidebar area
    $dynamic_sidebar = get_post_meta( $post->ID, 'dynamic_sidebar', true );

    if ( is_active_sidebar( $dynamic_sidebar ) ) {
        // Do your stuff
    }
?>

Changing before_widget and after_widget

On your functions.php file just add the following code, don't forget to change 'function_to_return_my_new_*' to your own function

<?php
    add_filter( 'ds_sidebar_description', 'function_to_return_my_new_sidebar_description' );
    add_filter( 'ds_before_widget', 'function_to_return_my_new_before_widget' );
    add_filter( 'ds_after_widget', 'function_to_return_my_new_after_widget' );
    add_filter( 'ds_before_title', 'function_to_return_my_new_before_title' );
    add_filter( 'ds_after_title', 'function_to_return_my_new_after_title' );
?>

Here is an example:

<?php
    add_filter( 'ds_before_widget', 'function_to_return_my_new_before_widget' );
    add_filter( 'ds_after_widget', 'function_to_return_my_new_after_widget' );

    function ds_before_widget(){
        return '<div id="%1$s" class="widget-container %2$s">';
    }

    function ds_after_widget(){
        return '</div>';
    }
?>

Requires: 3.0 or higher
Compatible up to: 3.2.1
Last Updated: 2011-10-4
Downloads: 2,531

Average Rating

3 stars
(5 ratings)

Support

0 of 0 support threads in the last three weeks have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 100,2,2
100,1,1 40,5,2 67,3,2
100,1,1