Advertisement
alchymyth

content widget space

Jul 26th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. //widget space direct after content//
  2. //example sidebar code//
  3. register_sidebar(array(
  4. 'name'         => 'Content Widget Area',
  5. 'id'            => 'content-widget',
  6. 'description'   => 'a widget area direct after the content',
  7. 'before_widget' => '<li class="content-widget" id="%1$s">',
  8. 'after_widget'  => '</li>',
  9. 'before_title'  => '<h2>',
  10. 'after_title'   => '</h2>'    ));
  11.  
  12. add_filter('the_content','after_content_widget_space',20); //adjust the number for priority
  13.  
  14. function after_content_widget_space( $content ) {
  15. $sidebar = '';
  16.     ob_start();
  17.         if ( is_single() && is_active_sidebar( 'content-widget' ) ) :
  18.         $sidebar = '<ul class="content-widget-space">';
  19.         if ( !dynamic_sidebar( 'content-widget' ) ) : endif;
  20.         $sidebar .= ob_get_contents();
  21.         $sidebar .= '</ul>';
  22.         endif;
  23.     ob_end_clean();
  24. return $content . $sidebar;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement