Advertisement
catchmahesh

Remove redundant readmore from featured slider

Aug 18th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.26 KB | None | 0 0
  1. function fabulous_fluid_page_slider() {
  2.     $quantity   = apply_filters( 'fabulous_fluid_get_option', 'featured_slide_number' );
  3.  
  4.     $excerpt_more_text  = apply_filters( 'fabulous_fluid_get_option', 'excerpt_more_text' );
  5.  
  6.     global $post;
  7.  
  8.     $output         = '';
  9.     $number_of_page = 0;        // for number of pages
  10.     $page_list      = array();  // list of valid page ids
  11.  
  12.     //Get number of valid pages
  13.     for( $i = 1; $i <= $quantity; $i++ ){
  14.         if( apply_filters( 'fabulous_fluid_get_option', 'featured_slider_page_' . $i ) && apply_filters( 'fabulous_fluid_get_option', 'featured_slider_page_' . $i ) > 0 ){
  15.             $number_of_page++;
  16.  
  17.             $page_list  =   array_merge( $page_list, array( apply_filters( 'fabulous_fluid_get_option', 'featured_slider_page_' . $i ) ) );
  18.         }
  19.  
  20.     }
  21.  
  22.     if ( !empty( $page_list ) && $number_of_page > 0 ) {
  23.         $get_featured_posts = new WP_Query( array(
  24.             'posts_per_page'    => $quantity,
  25.             'post_type'         => 'page',
  26.             'post__in'          => $page_list,
  27.             'orderby'           => 'post__in'
  28.         ));
  29.  
  30.         $i=0;
  31.  
  32.         while ( $get_featured_posts->have_posts() ) {
  33.             $get_featured_posts->the_post();
  34.  
  35.             $i++;
  36.  
  37.             $title_attribute = the_title_attribute( array( 'echo' => false ) );
  38.  
  39.             $classes = 'page page-' . $post->ID . ' slider-box';
  40.  
  41.             if ( $i == 1 ) {
  42.                 $classes .= ' first';
  43.             }
  44.  
  45.             //Default value if there is no featurd image or first image
  46.             $image_url = get_template_directory_uri() . '/images/no-featured-image-1680x720.jpg';
  47.             $image     = '<img class="wp-post-image no-featured-image" src="'.get_template_directory_uri().'/images/no-featured-image-1680x720.jpg">';
  48.  
  49.             if ( has_post_thumbnail() ) {
  50.                 $image =  get_the_post_thumbnail( $post->ID, 'fabulous-fluid-slider', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'wp-post-image' ) );
  51.  
  52.                 $image_url = get_the_post_thumbnail_url( $post->ID, 'fabulous-fluid-slider' );
  53.             }
  54.             else {
  55.                 //Get the first image in page, returns false if there is no image
  56.                 $first_image = fabulous_fluid_get_first_image( $post->ID, 'fabulous-fluid-slider', array( 'title' => $title_attribute, 'alt' => $title_attribute ) );
  57.  
  58.                 //Set value of image as first image if there is an image present in the page
  59.                 if ( '' != $first_image ) {
  60.                     $image = $first_image;
  61.  
  62.                     $image_url = fabulous_fluid_get_first_image( $post->ID, 'fabulous-fluid-slider', '', true );
  63.                 }
  64.             }
  65.  
  66.             $tag = "a";
  67.  
  68.             $content = get_the_excerpt();
  69.             $content = preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/", null,$content);
  70.  
  71.             $output .= '
  72.             <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() ) . '">';
  73.  
  74.                 $output .=  $image;
  75.  
  76.                 $output .= '
  77.                 <div class="caption">
  78.                     <span class="vcenter">
  79.                         ' . the_title( '<span class="entry-title">','</span>', false ) . '
  80.  
  81.                         <span class="entry-content">' . wp_kses_post( $content ) . '</span>
  82.  
  83.                         <span class="more">' . esc_html( $excerpt_more_text ) . '</span>
  84.                     </span><!-- .vcenter -->
  85.                 </div><!-- .caption -->
  86.             </a><!-- .slider-box -->';
  87.         } //endwhile
  88.  
  89.         wp_reset_query();
  90.     }
  91.     return $output;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement