Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Put this into functions.php of a child theme of catch everest wordpress theme
- /**
- * Shows Featued Post Slider
- *
- * @uses catcheverest_header action to add it in the header
- */
- function catcheverest_post_sliders_custom() {
- //delete_transient( 'catcheverest_post_sliders' );
- global $post;
- global $catcheverest_options_settings;
- $options = $catcheverest_options_settings;
- if( ( !$catcheverest_post_sliders = get_transient( 'catcheverest_post_sliders' ) ) && !empty( $options[ 'featured_slider' ] ) ) {
- echo '<!-- refreshing cache -->';
- $catcheverest_post_sliders = '
- <div id="main-slider" class="container">
- <section class="featured-slider">';
- $get_featured_posts = new WP_Query( array(
- 'posts_per_page' => $options[ 'slider_qty' ],
- 'post_type' => array( 'post', 'page' ),
- 'post__in' => $options[ 'featured_slider' ],
- 'orderby' => 'post__in',
- 'ignore_sticky_posts' => 1 // ignore sticky posts
- ));
- $i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
- $title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
- $excerpt = get_the_excerpt();
- if ( $i == 1 ) { $classes = "post hentry slides displayblock"; } else { $classes = "post hentry slides displaynone"; }
- $catcheverest_post_sliders .= '
- <article class="'.$classes.'">
- <figure class="slider-image">
- <a title="Permalink to '.the_title('','',false).'" href="' . get_permalink() . '">
- '. get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ).'
- </a>
- </figure>
- <div class="entry-container">
- <header class="entry-header">
- <h1 class="entry-title">
- <a title="Permalink to '.the_title('','',false).'" href="' . get_permalink() . '">'.the_title( '<span>','</span>', false ).'</a>
- </h1>
- </header>';
- if( $excerpt !='') {
- $catcheverest_post_sliders .= '<div class="entry-content">'. $excerpt.'</div>';
- }
- $catcheverest_post_sliders .= '
- </div>
- </article><!-- .slides -->';
- endwhile; wp_reset_query();
- $catcheverest_post_sliders .= '
- </section>
- <div id="slider-nav">
- <a class="slide-previous"><</a>
- <a class="slide-next">></a>
- </div>
- <div id="controllers"></div>
- </div><!-- #main-slider -->';
- set_transient( 'catcheverest_post_sliders', $catcheverest_post_sliders, 86940 );
- }
- echo $catcheverest_post_sliders;
- } // catcheverest_post_sliders
- /**
- * Shows Slider
- */
- function catcheverest_slider_display_custom() {
- global $catcheverest_options_settings;
- $options = $catcheverest_options_settings;
- $enableslider = $options[ 'enable_slider' ];
- $featuredslider = $options[ 'featured_slider' ];
- if ( ( $enableslider == 'enable-slider-allpage' ) || ( ( is_home() || is_front_page() ) && $enableslider == 'enable-slider-homepage' ) ) :
- // This function passes the value of slider effect to js file
- if ( function_exists( 'catcheverest_pass_slider_value' ) ) : catcheverest_pass_slider_value(); endif;
- // Select Slider
- if ( !empty( $featuredslider ) ) {
- catcheverest_post_sliders_custom();
- }
- else {
- catcheverest_default_sliders();
- }
- endif;
- }
- function catcheverest_exchange_slider_display_function() {
- remove_action( 'catcheverest_before_main', 'catcheverest_slider_display', 10);
- add_action( 'catcheverest_before_main', 'catcheverest_slider_display_custom');
- }
- add_action( 'init', 'catcheverest_exchange_slider_display_function' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement