Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lucida_post_page_category_slider( $options ) {
- global $post;
- $quantity = $options['featured_slider_number'];
- $no_of_post = 0; // for number of posts
- $post_list = array();// list of valid post/page ids
- $type = $options['featured_slider_type'];
- $show_content = $options['featured_slider_content_show'];
- $output = '';
- $args = array(
- 'post_type' => 'any',
- 'orderby' => 'rand(x)',
- 'order' => 'DESC',
- 'ignore_sticky_posts' => 1 // ignore sticky posts
- );
- //Get valid number of posts
- if( 'post' == $type || 'page' == $type ) {
- for( $i = 1; $i <= $quantity; $i++ ){
- $post_id = '';
- if( 'post' == $type ) {
- $post_id = isset( $options['featured_slider_post_' . $i] ) ? $options['featured_slider_post_' . $i] : false;
- }
- elseif( 'page' == $type ) {
- $post_id = isset( $options['featured_slider_page_' . $i] ) ? $options['featured_slider_page_' . $i] : false;
- }
- if ( $post_id && '' != $post_id ) {
- $post_list = array_merge( $post_list, array( $post_id ) );
- $no_of_post++;
- }
- }
- $args['post__in'] = $post_list;
- }
- elseif( 'category' == $type ) {
- $no_of_post = $quantity;
- $args['category__in'] = $options['featured_slider_select_category'];
- }
- if ( 0 == $no_of_post ) {
- return;
- }
- $args['posts_per_page'] = $no_of_post;
- $loop = new WP_Query( $args );
- $i=0;
- while ( $loop->have_posts()) : $loop->the_post(); $i++;
- $title_attribute = the_title_attribute( 'echo=0' );
- if ( $i == 1 ) {
- $classes = 'post post-'.$post->ID.' hentry slides displayblock';
- } else {
- $classes = 'post post-'.$post->ID.' hentry slides displaynone';
- }
- $output .= '
- <article class="' . $classes . '">
- <figure class="slider-image">';
- if ( has_post_thumbnail() ) {
- $output .= '<a title="' . $title_attribute . '" href="' . esc_url( get_permalink() ) . '">
- '. get_the_post_thumbnail( $post->ID, 'lucida-slider', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'attached-post-image' ) ).'
- </a>';
- }
- else {
- //Default value if there is no first image
- $lucida_image = '<img class="wp-post-image" src="'.esc_url( get_template_directory_uri() ).'/images/gallery/no-featured-image-1920x800.jpg" >';
- //Get the first image in page, returns false if there is no image
- $lucida_first_image = lucida_get_first_image( $post->ID, 'lucida-slider', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'attached-post-image' ) );
- //Set value of image as first image if there is an image present in the page
- if ( '' != $lucida_first_image ) {
- $lucida_image = $lucida_first_image;
- }
- $output .= '<a title="' . $title_attribute . '" href="' . esc_url( get_permalink() ) . '">
- '. $lucida_image .'
- </a>';
- }
- $output .= '
- </figure><!-- .slider-image -->
- <div class="slider-content-wrapper">
- <div class="entry-container">
- <header class="entry-header">
- <h2 class="entry-title">
- <a title="' . $title_attribute . '" href="' . esc_url( get_permalink() ) . '">'.the_title( '<span>','</span>', false ).'</a>
- </h2>
- <p class="entry-meta">' . lucida_page_post_meta() . '</p><!-- .entry-meta -->
- </header>
- ';
- if ( 'excerpt' == $show_content ) {
- $excerpt = get_the_excerpt();
- $output .= '<div class="entry-summary"><p>' . $excerpt . '</p></div><!-- .entry-summary -->';
- } elseif ( 'full-content' == $show_content ) {
- $content = apply_filters( 'the_content', get_the_content() );
- $content = str_replace( ']]>', ']]>', $content );
- $output .= '<div class="entry-content">' . wp_kses_post( $content ) . '</div><!-- .entry-content -->';
- }
- $output .= '
- </div><!-- .entry-container -->
- </div><!-- .slider-content-wrapper -->
- </article><!-- .slides -->';
- endwhile;
- wp_reset_postdata();
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement