Created
April 29, 2013 07:57
-
-
Save woogist/5480269 to your computer and use it in GitHub Desktop.
Display a slider of related posts at the bottom of a post. Posts are filtered by both tags and categories.
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
| /* | |
| * Woo Related posts slider hooked on woo_post_after | |
| */ | |
| function woo_related_posts_slider() { | |
| global $post; | |
| if( is_single() ){ | |
| $extra_args = array(); | |
| $terms_tags = get_the_terms( $post->ID, 'post_tag' ); | |
| $count = 0; | |
| if ( !empty( $terms_tags ) ) { | |
| $extra_args['tag'] = ''; | |
| foreach( $terms_tags as $k => $v) { | |
| $count++; | |
| if ( $count > 1 ) { | |
| $extra_args['tag'] .= '+'; | |
| } | |
| $extra_args['tag'] .= esc_attr($v->slug); | |
| } | |
| } | |
| $terms_categories = get_the_terms( $post->ID, 'category' ); | |
| $count = 0; | |
| if ( !empty( $terms_categories ) ) { | |
| $extra_args['category'] = ''; | |
| foreach ( $terms_categories as $k => $v ) { | |
| $count++; | |
| if ( $count > 1 ) { | |
| $extra_args['category'] .= ','; | |
| } | |
| $extra_args['category'] .= esc_attr( $v->slug ); | |
| } | |
| } | |
| $extra_args['link_title'] = 'true'; | |
| $extra_args['limit'] = '6'; | |
| $extra_args['overlay'] = 'full'; | |
| $extra_args['layout'] = 'text-bottom'; | |
| wooslider( array( 'slider_type' => 'posts', 'smoothheight' => 'true', 'randomize' => 'true' ), $extra_args ); | |
| } | |
| } | |
| add_action( 'woo_post_after', 'woo_related_posts_slider' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment