have_posts() ) : $sliderposts->the_post(); $style = ''; /* Slider background image*/ if ( $graphene_settings['slider_display_style'] == 'bgimage-excerpt' ) { $image = graphene_get_slider_image( get_the_ID(), 'graphene_slider', true); if ( $image ){ $style .= 'style="background-image:url('; $style .= ( is_array( $image ) ) ? $image[0] : $image; $style .= ');"'; } } $slider_link_url = esc_url( graphene_get_post_meta( get_the_ID(), 'slider_url' ) ); if ( ! $slider_link_url ) $slider_link_url = get_permalink(); $slider_link_url = apply_filters( 'graphene_slider_link_url', $slider_link_url, get_the_ID() ); ?>
id="slider-post-" >

'. get_the_title(). ''; $i++; endwhile; wp_reset_postdata(); ?>
tag of the the slider image. * * It requires the post's ID to be passed in as argument so that the user settings in * individual post / page can be retrieved. */ function graphene_get_slider_image( $post_id = NULL, $size = 'thumbnail', $urlonly = false, $default = '' ){ global $graphene_settings; // Throw an error message if no post ID supplied if ( $post_id == NULL){ echo 'ERROR: Post ID must be passed as an input argument to call the function graphene_get_slider_image().'; return; } // First get the settings $global_setting = ( $graphene_settings['slider_img'] ) ? $graphene_settings['slider_img'] : 'featured_image'; $local_setting = graphene_get_post_meta( $post_id, 'slider_img' ); $local_setting = ( $local_setting ) ? $local_setting : ''; // Determine which image should be displayed $final_setting = ( $local_setting == '' ) ? $global_setting : $local_setting; // Build the html based on the final setting $html = ''; if ( $final_setting == 'disabled' ){ // image disabled return false; } elseif ( $final_setting == 'featured_image' ){ // Featured Image if ( has_post_thumbnail( $post_id ) ) : if ( $urlonly ) $html = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size ); else $html .= get_the_post_thumbnail( $post_id, $size ); endif; } elseif ( $final_setting == 'post_image' ){ // First image in post $html = graphene_get_post_image( $post_id, $size, '', $urlonly); } elseif ( $final_setting == 'custom_url' ){ // Custom URL if ( ! $urlonly ){ $html .= ''; if ( $local_setting != '' ) : $html .= ''; else : $html .= ''; endif; } else { if ( $local_setting != '' ) : $html .= esc_url( graphene_get_post_meta( $post_id, 'slider_imgurl' ) ); else : $html .= esc_url( $graphene_settings['slider_imgurl'] ); endif; } } if ( ! $html ) $html = $default; // Returns the html return $html; } endif; /** * Returns the posts to be displayed in the slider * * @return object Object containing the slider posts * @package Graphene * @since 1.6 */ if ( ! function_exists( 'graphene_get_slider_posts' ) ) : function graphene_get_slider_posts(){ global $graphene_settings; /* Get the category whose posts should be displayed here. */ $slidertype = ( $graphene_settings['slider_type'] != '' ) ? $graphene_settings['slider_type'] : false; /* Set the post types to be displayed */ $slider_post_type = ( in_array( $slidertype, array( 'posts_pages', 'categories' ) ) ) ? array( 'post', 'page' ) : array( 'post' ) ; $slider_post_type = apply_filters( 'graphene_slider_post_type', $slider_post_type ); /* Get the number of posts to show */ $postcount = ( $graphene_settings['slider_postcount'] ) ? $graphene_settings['slider_postcount'] : 5 ; $args = array( 'posts_per_page' => $postcount, 'orderby' => 'menu_order date', 'order' => 'DESC', 'suppress_filters' => 0, 'post_type' => $slider_post_type, 'ignore_sticky_posts' => 1, // otherwise the sticky posts show up undesired ); if ( $slidertype && $slidertype == 'random' ) { $args = array_merge( $args, array( 'orderby' => 'rand' ) ); } if ( $slidertype && $slidertype == 'posts_pages' ) { $post_ids = $graphene_settings['slider_specific_posts']; $post_ids = preg_split("/[\s]*[,][\s]*/", $post_ids, -1, PREG_SPLIT_NO_EMPTY); // post_ids are comma separated, the query needs a array $post_ids = graphene_object_id( $post_ids ); $args = array_merge( $args, array( 'post__in' => $post_ids, 'posts_per_page' => -1, 'orderby' => 'post__in' ) ); } if ( $slidertype && $slidertype == 'categories' && is_array( $graphene_settings['slider_specific_categories'] ) ) { $cats = $graphene_settings['slider_specific_categories']; $cats = graphene_object_id( $cats, 'category' ); $args = array_merge( $args, array( 'category__in' => $cats ) ); if ( $graphene_settings['slider_random_category_posts'] ) $args = array_merge( $args, array( 'orderby' => 'rand' ) ); } /* Get the posts */ $sliderposts = new WP_Query( apply_filters( 'graphene_slider_args', $args ) ); return apply_filters( 'graphene_slider_posts', $sliderposts ); } endif; /** * Exclude posts that belong to the categories displayed in slider from the posts listing */ function graphene_exclude_slider_categories( $request ){ global $graphene_settings, $graphene_defaults; if ( $graphene_settings['slider_type'] != 'categories' ) return $request; if ( is_admin() ) return $request; if ( $graphene_settings['slider_exclude_categories'] != $graphene_defaults['slider_exclude_categories'] ){ $dummy_query = new WP_Query(); $dummy_query->parse_query( $request ); if ( get_option( 'show_on_front' ) == 'page' && $dummy_query->query_vars['page_id'] == get_option( 'page_on_front' ) ) return $request; if ( ( $graphene_settings['slider_exclude_categories'] == 'everywhere' ) || $graphene_settings['slider_exclude_categories'] == 'homepage' && $dummy_query->is_home() ) $request['category__not_in'] = graphene_object_id( $graphene_settings['slider_specific_categories'], 'category' ); } return $request; } add_filter( 'request', 'graphene_exclude_slider_categories' );