コード例 #1
0
    if (!empty($theme_option['archive-num-excerpt'])) {
        global $gdlr_excerpt_length;
        $gdlr_excerpt_length = $theme_option['archive-num-excerpt'];
        add_filter('excerpt_length', 'gdlr_set_excerpt_length');
    }
    global $wp_query, $gdlr_post_settings;
    $gdlr_lightbox_id++;
    $gdlr_post_settings['excerpt'] = intval($theme_option['archive-num-excerpt']);
    $gdlr_post_settings['thumbnail-size'] = $theme_option['archive-thumbnail-size'];
    $gdlr_post_settings['blog-style'] = $theme_option['archive-blog-style'];
    echo '<div class="blog-item-holder">';
    if ($theme_option['archive-blog-style'] == 'blog-full') {
        echo gdlr_get_blog_full($wp_query);
    } else {
        if ($theme_option['archive-blog-style'] == 'blog-medium') {
            echo gdlr_get_blog_medium($wp_query);
        } else {
            $blog_size = str_replace('blog-1-', '', $theme_option['archive-blog-style']);
            echo gdlr_get_blog_grid($wp_query, $blog_size, 'fitRows');
        }
    }
    echo '</div>';
    remove_filter('excerpt_length', 'gdlr_set_excerpt_length');
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    echo gdlr_get_pagination($wp_query->max_num_pages, $paged);
} else {
    ?>
<div class="gdlr-item page-not-found-item">
	<div class="page-not-found-block" >
		<div class="page-not-found-icon">
		<?php 
コード例 #2
0
 function gdlr_get_blog_item($settings = array())
 {
     $item_id = empty($settings['page-item-id']) ? '' : ' id="' . $settings['page-item-id'] . '" ';
     global $gdlr_spaces;
     $margin = !empty($settings['margin-bottom']) && $settings['margin-bottom'] != $gdlr_spaces['bottom-blog-item'] ? 'margin-bottom: ' . $settings['margin-bottom'] . ';' : '';
     $margin_style = !empty($margin) ? ' style="' . $margin . '" ' : '';
     $settings['title-type'] = empty($settings['title-type']) ? 'none' : $settings['title-type'];
     $settings['title'] = empty($settings['title']) ? '' : $settings['title'];
     $settings['caption'] = empty($settings['caption']) ? '' : $settings['caption'];
     $settings['icon'] = empty($settings['icon']) ? '' : $settings['icon'];
     $right_text = '';
     $right_text_class = '';
     $settings['right-text'] = empty($settings['right-text']) ? '' : $settings['right-text'];
     $settings['right-text-link'] = empty($settings['right-text-link']) ? '' : $settings['right-text-link'];
     if (!empty($settings['right-text-link'])) {
         $right_text_class = 'gdlr-right-text ';
         $right_text = '<a class="gdlr-right-text-link" href="' . $settings['right-text-link'] . '" >' . $settings['right-text'] . '</a>';
     }
     if ($settings['blog-layout'] == 'carousel') {
         $carousel = true;
         $right_text_class .= 'gdlr-nav-container ';
     }
     $ret = gdlr_get_item_title(array('title' => $settings['title'], 'caption' => $settings['caption'], 'icon' => $settings['icon'], 'type' => $settings['title-type'], 'carousel' => $carousel, 'additional_class' => $right_text_class, 'additional_html' => $right_text));
     $ret .= '<div class="blog-item-wrapper"  ' . $item_id . $margin_style . '>';
     // query post and sticky post
     $args = array('post_type' => 'post', 'suppress_filters' => false);
     if (!empty($settings['category']) || !empty($settings['tag'])) {
         $args['tax_query'] = array('relation' => 'OR');
         if (!empty($settings['category'])) {
             array_push($args['tax_query'], array('terms' => explode(',', $settings['category']), 'taxonomy' => 'category', 'field' => 'slug'));
         }
         if (!empty($settings['tag'])) {
             array_push($args['tax_query'], array('terms' => explode(',', $settings['tag']), 'taxonomy' => 'post_tag', 'field' => 'slug'));
         }
     }
     if ($settings['enable-sticky'] == 'enable') {
         if (get_query_var('paged') <= 1) {
             $sticky_args = $args;
             $sticky_args['post__in'] = get_option('sticky_posts');
             if (!empty($sticky_args['post__in'])) {
                 $sticky_query = new WP_Query($sticky_args);
             }
         }
         $args['post__not_in'] = get_option('sticky_posts', '');
     } else {
         $args['ignore_sticky_posts'] = 1;
     }
     $args['posts_per_page'] = empty($settings['num-fetch']) ? '5' : $settings['num-fetch'];
     $args['orderby'] = empty($settings['orderby']) ? 'post_date' : $settings['orderby'];
     $args['order'] = empty($settings['order']) ? 'desc' : $settings['order'];
     $args['paged'] = get_query_var('paged') ? get_query_var('paged') : get_query_var('page');
     $args['paged'] = empty($args['paged']) ? 1 : $args['paged'];
     $args['offset'] = empty($settings['offset']) ? 0 : $settings['offset'];
     $query = new WP_Query($args);
     // merge query
     if (!empty($sticky_query)) {
         $query->posts = array_merge($sticky_query->posts, $query->posts);
         $query->post_count = $sticky_query->post_count + $query->post_count;
     }
     // set the excerpt length
     if (!empty($settings['num-excerpt'])) {
         global $gdlr_excerpt_length;
         $gdlr_excerpt_length = $settings['num-excerpt'];
         add_filter('excerpt_length', 'gdlr_set_excerpt_length');
     }
     // get blog by the blog style
     global $gdlr_post_settings, $gdlr_lightbox_id;
     $gdlr_lightbox_id++;
     $gdlr_post_settings['excerpt'] = intval($settings['num-excerpt']);
     $gdlr_post_settings['thumbnail-size'] = $settings['thumbnail-size'];
     $gdlr_post_settings['blog-style'] = $settings['blog-style'];
     $ret .= '<div class="blog-item-holder">';
     if ($settings['blog-style'] == 'blog-full') {
         $gdlr_post_settings['blog-info'] = array('date', 'author', 'comment', 'category');
         $ret .= gdlr_get_blog_full($query);
     } else {
         if ($settings['blog-style'] == 'blog-medium') {
             $gdlr_post_settings['blog-info'] = array('date', 'author', 'comment', 'category');
             $ret .= gdlr_get_blog_medium($query);
         } else {
             if ($settings['blog-style'] == 'blog-grid-list') {
                 $gdlr_post_settings['blog-info'] = array('date', 'author');
                 $ret .= gdlr_get_blog_grid_list($query, $blog_size, $settings['blog-layout']);
             } else {
                 $gdlr_post_settings['blog-info'] = array('date', 'author');
                 $blog_size = str_replace('blog-1-', '', $settings['blog-style']);
                 $ret .= gdlr_get_blog_grid($query, $blog_size, $settings['blog-layout']);
             }
         }
     }
     $ret .= '</div>';
     if ($settings['pagination'] == 'enable') {
         $ret .= gdlr_get_pagination($query->max_num_pages, $args['paged']);
     }
     $ret .= '</div>';
     // blog-item-wrapper
     remove_filter('excerpt_length', 'gdlr_set_excerpt_length');
     return $ret;
 }