Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************** magbook Category SLIDERS ***********************************/
- function magbook_category_sliders() {
- global $post;
- $magbook_settings = magbook_get_theme_options();
- global $excerpt_length;
- $magbook_tag_text = $magbook_settings['magbook_tag_text'];
- $magbook_slider_design_layout = $magbook_settings['magbook_slider_design_layout'];
- $entry_format_meta_blog = $magbook_settings['magbook_entry_meta_blog'];
- $category = $magbook_settings['magbook_default_category_slider'];
- $magbook_small_slider_post_category = $magbook_settings['magbook_small_slider_post_category'];
- $query = new WP_Query(array(
- 'posts_per_page' => intval($magbook_settings['magbook_slider_number']),
- 'post_type' => array(
- 'post'
- ) ,
- 'category_name' => esc_attr($category),
- ));
- $small_query = new WP_Query(array(
- 'posts_per_page' => 4,
- 'post_type' => array(
- 'post'
- ) ,
- 'category_name' => esc_attr($magbook_small_slider_post_category),
- ));
- if(($query->have_posts() ) || ($small_query->have_posts() && !empty($magbook_small_slider_post_category) ) ){ ?>
- <div class="main-slider clearfix">
- <?php
- if ($magbook_slider_design_layout=='no-slider'){
- echo '<div class="no-slider">';
- } elseif ($magbook_slider_design_layout=='layer-slider'){
- echo '<div class="layer-slider">';
- } elseif ($magbook_slider_design_layout=='small-slider'){
- echo '<div class="small-slider">';
- } else {
- echo '<div class="multi-slider">';
- }
- echo '<ul class="slides">';
- while ($query->have_posts()):$query->the_post();
- $attachment_id = get_post_thumbnail_id();
- $image_attributes = wp_get_attachment_image_src($attachment_id,'magbook_slider_image');
- $title_attribute = apply_filters('the_title', get_the_title(get_queried_object_id()));
- $excerpt = get_the_excerpt();
- echo '<li>';
- if ($image_attributes) {
- echo '<div class="image-slider" title="'.the_title_attribute('echo=0').'"' .' style="background-image:url(' ."'" .esc_url($image_attributes[0])."'" .')">';
- }else{
- echo '<div class="image-slider">';
- }
- echo '<article class="slider-content">';
- if ($title_attribute != '' || $excerpt != '') {
- echo '<div class="slider-text-content">';
- if($entry_format_meta_blog != 'hide-meta' ){
- echo '<div class="entry-meta">';
- do_action('magbook_post_categories_list_id');
- echo '</div> <!-- end .entry-meta -->';
- }
- $remove_link = $magbook_settings['magbook_slider_link'];
- if($remove_link == 0){
- if ($title_attribute != '') {
- echo '<h2 class="slider-title"><a href="'.esc_url(get_permalink()).'" title="'.the_title_attribute('echo=0').'" rel="bookmark">'.get_the_title().'</a></h2><!-- .slider-title -->';
- }
- }else{
- echo '<h2 class="slider-title">'.get_the_title().'</h2><!-- .slider-title -->';
- }
- if ($excerpt != '') {
- echo '<p class="slider-text">'.wp_strip_all_tags( get_the_excerpt(), true ).'</p><!-- end .slider-text -->';
- }
- if($entry_format_meta_blog != 'hide-meta' ){
- echo '<div class="entry-meta">';
- echo '<span class="author vcard"><a href="'.get_author_posts_url( get_the_author_meta( 'ID' ) ).'" title="'.the_title_attribute('echo=0').'"><i class="fa fa-user-o"></i> ' .esc_attr(get_the_author()).'</a></span>';
- printf( '<span class="posted-on"><a href="%1$s" title="%2$s"><i class="fa fa-calendar-o"></i> %3$s</a></span>',
- esc_url(get_the_permalink()),
- esc_attr( get_the_time(get_option( 'date_format' )) ),
- esc_attr( get_the_time(get_option( 'date_format' )) )
- );
- if ( comments_open()) { ?>
- <span class="comments">
- <?php comments_popup_link( __( '<i class="fa fa-comment-o"></i> No Comments', 'magbook' ), __( '<i class="fa fa-comment-o"></i> 1 Comment', 'magbook' ), __( '<i class="fa fa-comment-o"></i> % Comments', 'magbook' ), '', __( 'Comments Off', 'magbook' ) ); ?> </span>
- <?php }
- echo '</div> <!-- end .entry-meta -->';
- }
- echo '</div><!-- end .slider-text-content -->';
- }
- if( $magbook_settings['magbook_slider_button'] == 0 && $magbook_tag_text !='' ){
- echo '<div class="slider-buttons">';
- echo '<a title='.'"'.the_title_attribute('echo=0'). '"'. ' '.'href="'.esc_url(get_permalink()).'"'.' class="btn-default">'.esc_attr($magbook_tag_text).'</a>';
- echo '</div><!-- end .slider-buttons -->';
- }
- echo '</article><!-- end .slider-content --> ';
- echo '</div><!-- end .image-slider -->
- </li>';
- endwhile;
- wp_reset_postdata(); ?>
- </ul><!-- end .slides -->
- </div> <!-- end .layer-slider -->
- <?php if ($magbook_settings['magbook_slider_design_layout']=='small-slider'){ ?>
- <div class="small-sld-cat">
- <?php
- while ($small_query->have_posts()):$small_query->the_post(); ?>
- <article id="post-<?php the_ID(); ?>" <?php post_class();?>>
- <div class="sld-cat-wrap">
- <?php if( has_post_thumbnail() ){ ?>
- <div class="sld-cat-image">
- <figure class="post-featured-image">
- <a href="<?php the_permalink();?>" title="<?php echo the_title_attribute('echo=0'); ?>">
- <?php the_post_thumbnail('magbook-featured-image'); ?>
- </a>
- </figure>
- <!-- end .post-featured-image -->
- </div>
- <!-- end .sld-cat-image -->
- <?php } ?>
- <div class="sld-cat-text">
- <header class="entry-header">
- <h2 class="entry-title">
- <a href="<?php the_permalink(); ?>" title="<?php echo the_title_attribute('echo=0'); ?>"> <?php the_title();?> </a>
- </h2>
- <!-- end.entry-title -->
- <?php if($entry_format_meta_blog != 'hide-meta' ){
- echo '<div class="entry-meta">';
- echo '<span class="author vcard"><a href="'.get_author_posts_url( get_the_author_meta( 'ID' ) ).'" title="'.the_title_attribute('echo=0').'"><i class="fa fa-user-o"></i> ' .esc_attr(get_the_author()).'</a></span>';
- printf( '<span class="posted-on"><a href="%1$s" title="%2$s"><i class="fa fa-calendar-o"></i> %3$s</a></span>',
- esc_url(get_the_permalink()),
- esc_attr( get_the_time(get_option( 'date_format' )) ),
- esc_attr( get_the_time(get_option( 'date_format' )) )
- ); ?>
- <?php if ( comments_open()) { ?>
- <span class="comments">
- <?php comments_popup_link( __( '<i class="fa fa-comment-o"></i> No Comments', 'magbook' ), __( '<i class="fa fa-comment-o"></i> 1 Comment', 'magbook' ), __( '<i class="fa fa-comment-o"></i> % Comments', 'magbook' ), '', __( 'Comments Off', 'magbook' ) ); ?> </span>
- <?php }
- echo '</div> <!-- end .entry-meta -->';
- } ?>
- </header>
- <!-- end .entry-header -->
- </div>
- <!-- end .sld-cat-text -->
- </div>
- <!-- end .sld-cat-wrap -->
- </article>
- <!-- end .post -->
- <?php endwhile;
- wp_reset_postdata(); ?>
- </div> <!-- end .small-sld-cat-->
- <?php } ?>
- </div> <!-- end .main-slider -->
- <?php }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement