示例#1
0
<div class="vce-grid-item">

    <div class="vce-grid-text">
    <?php 
$center_class = vce_get_option('lay_fa_grid_center') ? ' vce-vertical-center' : '';
?>
    <div class="vce-featured-info<?php 
echo $center_class;
?>
">
        <?php 
if (vce_get_option('lay_fa_grid_cat')) {
    ?>
            <div class="vce-featured-section">
                <?php 
    echo vce_get_category();
    ?>
            </div>
        <?php 
}
?>

        <h2 class="vce-featured-title">
            <a class="vce-featured-link-article" href="<?php 
echo esc_url(get_permalink());
?>
" title="<?php 
echo esc_attr(get_the_title());
?>
"><?php 
echo vce_get_title('lay-fa-grid');
示例#2
0
    function widget($args, $instance)
    {
        extract($args);
        $instance = wp_parse_args((array) $instance, $this->defaults);
        echo $before_widget;
        $title = apply_filters('widget_title', $instance['title']);
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $q_args = array('post_type' => 'post', 'posts_per_page' => $instance['numposts'], 'ignore_sticky_posts' => 1, 'orderby' => $instance['orderby']);
        if (!empty($instance['manual']) && !empty($instance['manual'][0])) {
            $q_args['posts_per_page'] = absint(count($instance['manual']));
            $q_args['orderby'] = 'post__in';
            $q_args['post__in'] = $instance['manual'];
            $q_args['post_type'] = array_keys(get_post_types(array('public' => true)));
            //support all existing public post types
        } else {
            if (!empty($instance['auto_detect']) && is_single()) {
                $cats = get_the_category();
                if (!empty($cats)) {
                    foreach ($cats as $k => $cat) {
                        $q_args['category__in'][] = $cat->term_id;
                    }
                }
            } else {
                if (!empty($instance['category'])) {
                    $q_args['category__in'] = is_array($instance['category']) ? $instance['category'] : array($instance['category']);
                }
            }
            if (!empty($instance['tag'])) {
                $q_args['tag_slug__in'] = explode(',', $instance['tag']);
            }
            if ($instance['orderby'] == 'views' && function_exists('ev_get_meta_key')) {
                $q_args['orderby'] = 'meta_value_num';
                $q_args['meta_key'] = ev_get_meta_key();
            }
            if ($instance['orderby'] == 'title') {
                $q_args['order'] = 'ASC';
            }
            if (!empty($instance['date_limit'])) {
                $q_args['date_query'] = array('after' => date('Y-m-d', vce_calculate_time_diff($instance['date_limit'])));
            }
        }
        $vce_posts = new WP_Query($q_args);
        $title_limit = isset($instance['title_limit']) && !empty($instance['title_limit']) ? $instance['title_limit'] : false;
        $title_more = isset($instance['title_more']) ? $instance['title_more'] : '...';
        $img_size = $instance['style'] == 'vce-post-list' ? 'vce-lay-d' : 'vce-fa-grid';
        if ($vce_posts->have_posts()) {
            ?>

		<?php 
            if ($instance['style'] == 'vce-post-slider' && $vce_posts->post_count == 1) {
                $instance['style'] = 'vce-post-big';
            }
            ?>

		<ul class="<?php 
            echo $instance['style'];
            ?>
">

			<?php 
            while ($vce_posts->have_posts()) {
                $vce_posts->the_post();
                ?>

		 		<li>
		 			<?php 
                $p_title = $title_limit ? vce_trim_chars(strip_tags(get_the_title()), $title_limit, $title_more) : get_the_title();
                ?>
		 			
		 			<a href="<?php 
                echo esc_url(get_permalink());
                ?>
" class="featured_image_sidebar" title="<?php 
                echo esc_attr(get_the_title());
                ?>
"><span class="vce-post-img"><?php 
                echo vce_featured_image($img_size);
                ?>
</span></a>
		 			<div class="vce-posts-wrap">
		 				<?php 
                if (!empty($instance['cat_link'])) {
                    ?>
							<span class="meta-category"><?php 
                    echo vce_get_category();
                    ?>
</span>
						<?php 
                }
                ?>
			 			<a href="<?php 
                echo esc_url(get_permalink());
                ?>
" title="<?php 
                echo esc_attr(get_the_title());
                ?>
" class="vce-post-link"><?php 
                echo $p_title;
                ?>
</a>
			 			<?php 
                if (!empty($instance['meta']) && ($meta = vce_get_meta_data('', $instance['meta']))) {
                    ?>
			 				<div class="entry-meta"><?php 
                    echo $meta;
                    ?>
</div>
			 			<?php 
                }
                ?>
		 			</div>
		 		</li>
			<?php 
            }
            ?>

		  </ul>
		<?php 
        }
        ?>

		<?php 
        wp_reset_postdata();
        ?>

		<?php 
        echo $after_widget;
    }