Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fabulous_fluid_page_slider() {
- $quantity = apply_filters( 'fabulous_fluid_get_option', 'featured_slide_number' );
- $excerpt_more_text = apply_filters( 'fabulous_fluid_get_option', 'excerpt_more_text' );
- global $post;
- $output = '';
- $number_of_page = 0; // for number of pages
- $page_list = array(); // list of valid page ids
- //Get number of valid pages
- for( $i = 1; $i <= $quantity; $i++ ){
- if( apply_filters( 'fabulous_fluid_get_option', 'featured_slider_page_' . $i ) && apply_filters( 'fabulous_fluid_get_option', 'featured_slider_page_' . $i ) > 0 ){
- $number_of_page++;
- $page_list = array_merge( $page_list, array( apply_filters( 'fabulous_fluid_get_option', 'featured_slider_page_' . $i ) ) );
- }
- }
- if ( !empty( $page_list ) && $number_of_page > 0 ) {
- $get_featured_posts = new WP_Query( array(
- 'posts_per_page' => $quantity,
- 'post_type' => 'page',
- 'post__in' => $page_list,
- 'orderby' => 'post__in'
- ));
- $i=0;
- while ( $get_featured_posts->have_posts() ) {
- $get_featured_posts->the_post();
- $i++;
- $title_attribute = the_title_attribute( array( 'echo' => false ) );
- $classes = 'page page-' . $post->ID . ' slider-box';
- if ( $i == 1 ) {
- $classes .= ' first';
- }
- //Default value if there is no featurd image or first image
- $image_url = get_template_directory_uri() . '/images/no-featured-image-1680x720.jpg';
- $image = '<img class="wp-post-image no-featured-image" src="'.get_template_directory_uri().'/images/no-featured-image-1680x720.jpg">';
- if ( has_post_thumbnail() ) {
- $image = get_the_post_thumbnail( $post->ID, 'fabulous-fluid-slider', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'wp-post-image' ) );
- $image_url = get_the_post_thumbnail_url( $post->ID, 'fabulous-fluid-slider' );
- }
- else {
- //Get the first image in page, returns false if there is no image
- $first_image = fabulous_fluid_get_first_image( $post->ID, 'fabulous-fluid-slider', array( 'title' => $title_attribute, 'alt' => $title_attribute ) );
- //Set value of image as first image if there is an image present in the page
- if ( '' != $first_image ) {
- $image = $first_image;
- $image_url = fabulous_fluid_get_first_image( $post->ID, 'fabulous-fluid-slider', '', true );
- }
- }
- $tag = "a";
- $content = get_the_excerpt();
- $content = preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/", null,$content);
- $output .= '
- <a class="' . $classes . '" data-cycle-pager-template="<div class=\'thumbnail thumbnail-' . $i . '\'><span class=\'cover\'></span>' . the_title( '<h2>','</h2>', false ) . '<img src=\'' . esc_url( $image_url ) .'\'></div>" title="'. $title_attribute . '" href="' . esc_url( get_permalink() ) . '">';
- $output .= $image;
- $output .= '
- <div class="caption">
- <span class="vcenter">
- ' . the_title( '<span class="entry-title">','</span>', false ) . '
- <span class="entry-content">' . wp_kses_post( $content ) . '</span>
- <span class="more">' . esc_html( $excerpt_more_text ) . '</span>
- </span><!-- .vcenter -->
- </div><!-- .caption -->
- </a><!-- .slider-box -->';
- } //endwhile
- wp_reset_query();
- }
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement