Forked from idavinder/Add widget after 2 or 3 posts in Genesis Theme
Created
August 2, 2016 18:47
-
-
Save Temmyhlee/440a1c609a1e1dea8bc690b1be446d8c to your computer and use it in GitHub Desktop.
New Widget between Posts in Genesis Theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* Add new widget Between Posts Area | |
genesis_register_sidebar( array( | |
'id' => 'between-posts-area', | |
'name' => __( 'Between Posts Area', 'basicwp-theme' ), | |
'description' => __( 'This widget show between and after few posts.', 'basicwp-theme' ), | |
) ); | |
//* Add widget area between and after 3 posts | |
add_action( 'genesis_after_entry', 'basicwptheme_between_posts_area' ); | |
function basicwptheme_between_posts_area() { | |
global $loop_counter; | |
$loop_counter++; | |
if( $loop_counter == 3 ) { | |
if ( is_active_sidebar( 'between-posts-area' ) ) { | |
echo '<div class="between-posts-area widget-area"><div class="wrap">'; | |
dynamic_sidebar( 'between-posts-area' ); | |
echo '</div></div><!-- end .top -->'; | |
} | |
$loop_counter = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment