Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* WIDGET AREAS aka SIDEBARS INBETWEEN POSTS IN LOOP OF INDEX PAGE */
- add_action( 'after_setup_theme', 'twentyfifteen_child_setup' );
- function twentyfifteen_child_setup() {
- add_action( 'widgets_init', 'twentyfifteen_child_widgets_init' );
- add_filter( 'body_class', 'twentyfifteen_child_body_class' );
- add_action( 'the_post', 'twentyfifteen_child_inter_posts_sidebars' );
- }
- //register sidebar for inbetween posts
- function twentyfifteen_child_widgets_init() {
- register_sidebar( array(
- 'name' => __( 'First Inter-Posts Widget Area ', 'twentyfifteen' ),
- 'id' => 'inter-posts-1',
- 'description' => __( 'Add widgets here to appear between post 1 and 2 in your index page.', 'twentyfifteen' ),
- 'before_widget' => '<aside id="%1$s" class="widget inter-post-widget %2$s">',
- 'after_widget' => '</aside>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- }
- //body class correction
- function twentyfifteen_child_body_class( $classes ) {
- if ( is_active_sidebar( 'inter-posts-1' ) ) {
- if( is_home() ) $classes[] = 'widgets-between-posts';
- }
- return $classes;
- }
- //widget output between posts in index page
- function twentyfifteen_child_inter_posts_sidebars() {
- global $wp_query;
- if( is_home() && $wp_query->current_post == 1 ) {
- dynamic_sidebar( 'inter-posts-1' );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement