Advertisement
Guest User

display pages as post sliders in catch everest child theme

a guest
Mar 26th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.66 KB | None | 0 0
  1. // Put this into functions.php of a child theme of catch everest wordpress theme
  2.  
  3. /**
  4.  * Shows Featued Post Slider
  5.  *
  6.  * @uses catcheverest_header action to add it in the header
  7.  */
  8. function catcheverest_post_sliders_custom() {
  9.     //delete_transient( 'catcheverest_post_sliders' );
  10.    
  11.     global $post;
  12.     global $catcheverest_options_settings;
  13.     $options = $catcheverest_options_settings;
  14.  
  15.      
  16.     if( ( !$catcheverest_post_sliders = get_transient( 'catcheverest_post_sliders' ) ) && !empty( $options[ 'featured_slider' ] ) ) {
  17.         echo '<!-- refreshing cache -->';
  18.        
  19.         $catcheverest_post_sliders = '
  20.         <div id="main-slider" class="container">
  21.             <section class="featured-slider">';
  22.                 $get_featured_posts = new WP_Query( array(
  23.                     'posts_per_page' => $options[ 'slider_qty' ],
  24.                     'post_type' => array( 'post', 'page' ),
  25.                     'post__in'       => $options[ 'featured_slider' ],
  26.                     'orderby'        => 'post__in',
  27.                     'ignore_sticky_posts' => 1 // ignore sticky posts
  28.                 ));
  29.                 $i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
  30.                     $title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
  31.                     $excerpt = get_the_excerpt();
  32.                     if ( $i == 1 ) { $classes = "post hentry slides displayblock"; } else { $classes = "post hentry slides displaynone"; }
  33.                     $catcheverest_post_sliders .= '
  34.                     <article class="'.$classes.'">
  35.                         <figure class="slider-image">
  36.                             <a title="Permalink to '.the_title('','',false).'" href="' . get_permalink() . '">
  37.                                 '. get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class'  => 'pngfix' ) ).'
  38.                             </a>   
  39.                         </figure>
  40.                         <div class="entry-container">
  41.                             <header class="entry-header">
  42.                                 <h1 class="entry-title">
  43.                                     <a title="Permalink to '.the_title('','',false).'" href="' . get_permalink() . '">'.the_title( '<span>','</span>', false ).'</a>
  44.                                 </h1>
  45.                             </header>';
  46.                             if( $excerpt !='') {
  47.                                 $catcheverest_post_sliders .= '<div class="entry-content">'. $excerpt.'</div>';
  48.                             }
  49.                             $catcheverest_post_sliders .= '
  50.                         </div>
  51.                     </article><!-- .slides -->';               
  52.                 endwhile; wp_reset_query();
  53.                 $catcheverest_post_sliders .= '
  54.             </section>
  55.             <div id="slider-nav">
  56.                 <a class="slide-previous">&lt;</a>
  57.                 <a class="slide-next">&gt;</a>
  58.             </div>
  59.             <div id="controllers"></div>
  60.         </div><!-- #main-slider -->';
  61.            
  62.     set_transient( 'catcheverest_post_sliders', $catcheverest_post_sliders, 86940 );
  63.     }
  64.     echo $catcheverest_post_sliders;   
  65. } // catcheverest_post_sliders 
  66.  
  67. /**
  68.  * Shows Slider
  69.  */
  70. function catcheverest_slider_display_custom() {
  71.     global $catcheverest_options_settings;
  72.     $options = $catcheverest_options_settings;
  73.  
  74.     $enableslider = $options[ 'enable_slider' ];
  75.     $featuredslider = $options[ 'featured_slider' ];
  76.    
  77.     if ( ( $enableslider == 'enable-slider-allpage' ) || ( ( is_home() || is_front_page() ) && $enableslider == 'enable-slider-homepage' ) ) :
  78.         // This function passes the value of slider effect to js file
  79.         if ( function_exists( 'catcheverest_pass_slider_value' ) ) : catcheverest_pass_slider_value(); endif;
  80.         // Select Slider
  81.         if ( !empty( $featuredslider ) ) {
  82.             catcheverest_post_sliders_custom();
  83.         }
  84.         else {
  85.             catcheverest_default_sliders();
  86.         }
  87.     endif; 
  88. }
  89.  
  90. function catcheverest_exchange_slider_display_function() {
  91.     remove_action( 'catcheverest_before_main', 'catcheverest_slider_display', 10);
  92.     add_action( 'catcheverest_before_main', 'catcheverest_slider_display_custom');
  93. }
  94. add_action( 'init', 'catcheverest_exchange_slider_display_function' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement