catchresponsive_page_slider

This function to display featured page slider.

Description

catchresponsive_page_slider( $options ); 

Parameters (1)

0. $options
Catchresponsive_theme_options from customizer

Usage

  1. if ( !function_exists( 'catchresponsive_page_slider' ) ) { 
  2. require_once '/inc/catchresponsive-featured-slider.php'; 
  3.  
  4. // catchresponsive_theme_options from customizer 
  5. $options = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = catchresponsive_page_slider($options); 
  9.  

Defined (1)

The function is defined in the following location(s).

/inc/catchresponsive-featured-slider.php  
  1. function catchresponsive_page_slider( $options ) { 
  2. $quantity = $options['featured_slide_number']; 
  3. $more_link_text = $options['excerpt_more_text']; 
  4.  
  5. global $post; 
  6.  
  7. $catchresponsive_page_slider = ''; 
  8. $number_of_page = 0; // for number of pages 
  9. $page_list = array(); // list of valid page ids 
  10.  
  11. //Get number of valid pages 
  12. for( $i = 1; $i <= $quantity; $i++ ) { 
  13. if ( isset ( $options['featured_slider_page_' . $i] ) && $options['featured_slider_page_' . $i] > 0 ) { 
  14. $number_of_page++; 
  15.  
  16. $page_list = array_merge( $page_list, array( $options['featured_slider_page_' . $i] ) ); 
  17.  
  18.  
  19. if ( !empty( $page_list ) && $number_of_page > 0 ) { 
  20. $get_featured_posts = new WP_Query( array( 
  21. 'posts_per_page' => $quantity,  
  22. 'post_type' => 'page',  
  23. 'post__in' => $page_list,  
  24. 'orderby' => 'post__in' 
  25. )); 
  26. $i=0; 
  27.  
  28. while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++; 
  29. $title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to: ', 'catch-responsive' ), 'echo' => false ) ); 
  30. $excerpt = get_the_excerpt(); 
  31. if ( $i == 1 ) { $classes = 'page pageid-'.$post->ID.' hentry slides displayblock'; } else { $classes = 'page pageid-'.$post->ID.' hentry slides displaynone'; } 
  32. $catchresponsive_page_slider .= ' 
  33. <article class="'.$classes.'"> 
  34. <figure class="slider-image">'; 
  35. if ( has_post_thumbnail() ) { 
  36. $catchresponsive_page_slider .= '<a title="Permalink to '.the_title('', '', false).'" href="' . get_permalink() . '"> 
  37. '. get_the_post_thumbnail( $post->ID, 'catchresponsive-slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'attached-page-image' ) ).' 
  38. </a>'; 
  39. else { 
  40. //Default value if there is no first image 
  41. $catchresponsive_image = '<img class="pngfix wp-post-image" src="'.get_template_directory_uri().'/images/gallery/no-featured-image-1200x514.jpg" >'; 
  42.  
  43. //Get the first image in page, returns false if there is no image 
  44. $catchresponsive_first_image = catchresponsive_get_first_image( $post->ID, 'catchresponsive-slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'attached-page-image' ) ); 
  45.  
  46. //Set value of image as first image if there is an image present in the page 
  47. if ( '' != $catchresponsive_first_image ) { 
  48. $catchresponsive_image = $catchresponsive_first_image; 
  49.  
  50. $catchresponsive_page_slider .= '<a title="Permalink to '.the_title('', '', false).'" href="' . get_permalink() . '"> 
  51. '. $catchresponsive_image .' 
  52. </a>'; 
  53.  
  54. $catchresponsive_page_slider .= ' 
  55. </figure><!-- .slider-image --> 
  56. <div class="entry-container"> 
  57. <header class="entry-header"> 
  58. <h1 class="entry-title"> 
  59. <a title="Permalink to '.the_title('', '', false).'" href="' . get_permalink() . '">'.the_title( '<span>', '</span>', false ).'</a> 
  60. </h1> 
  61. <div class="assistive-text">'.catchresponsive_page_post_meta().'</div> 
  62. </header>'; 
  63. if ( $excerpt !='') { 
  64. $catchresponsive_page_slider .= '<div class="entry-content"><p>'. $excerpt.'</p></div>'; 
  65. $catchresponsive_page_slider .= ' 
  66. </div><!-- .entry-container --> 
  67. </article><!-- .slides -->'; 
  68. endwhile; 
  69.  
  70. wp_reset_query(); 
  71. return $catchresponsive_page_slider;