コード例 #1
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $pages = empty($instance['pages']) ? '' : $instance['pages'];
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
        <ul class="cp-widget clearfix"> <?php 
        $include_ids = explode(',', $pages);
        $args = array('post_type' => 'page', 'post__in' => $include_ids, 'orderby' => 'post__in');
        $widget_loop = new WP_Query($args);
        while ($widget_loop->have_posts()) {
            $widget_loop->the_post();
            ?>
			<li class="cp-wrap clearfix">
				<div class="cp-thumb-xl"><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><?php 
            if (has_post_thumbnail()) {
                the_post_thumbnail('cp_large');
            } else {
                echo '<img src="' . get_template_directory_uri() . '/images/noimage_cp_large.png' . '" alt="No Picture" />';
            }
            ?>
</a></div>
				<div class="cp-data">
					<h3 class="cp-xl-title"><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><?php 
            the_title();
            ?>
</a></h3>
				</div>
				<?php 
            mh_excerpt();
            ?>
			</li><?php 
        }
        wp_reset_postdata();
        ?>
        </ul><?php 
        echo $after_widget;
    }
コード例 #2
0
ファイル: loop-layout1.php プロジェクト: Gabriel-07/site
		<header class="loop-data">
			<h3 class="loop-title"><a href="<?php 
the_permalink();
?>
" rel="bookmark"><?php 
the_title();
?>
</a></h3>
			<?php 
mh_loop_meta();
?>
		</header>		
		<div class="loop-thumb">
			<a href="<?php 
the_permalink();
?>
">
				<?php 
if (has_post_thumbnail()) {
    the_post_thumbnail('loop');
} else {
    echo '<img src="' . get_template_directory_uri() . '/images/noimage_174x131.png' . '" alt="No Picture" />';
}
?>
			</a>
		</div>
		<?php 
mh_excerpt($excerpt_length);
?>
	</div>
</article>		
コード例 #3
0
    ?>
		<div class="loop-thumb">
			<a href="<?php 
    the_permalink();
    ?>
"><?php 
    echo $thumbnail;
    ?>
</a>
		</div>
	<?php 
}
?>
	<header class="loop-data">
		<h3 class="loop-title"><a href="<?php 
the_permalink();
?>
" rel="bookmark"><?php 
the_title();
?>
</a></h3>
		<p class="meta"><?php 
echo get_the_date() . ' | ';
mh_comment_count();
?>
</p>
	</header>
	<?php 
mh_excerpt($options['excerpt_length']);
?>
</article>
コード例 #4
0
    function widget($args, $instance)
    {
        extract($args);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $cats = empty($instance['cats']) ? '' : $instance['cats'];
        $tags = empty($instance['tags']) ? '' : $instance['tags'];
        $postcount = empty($instance['postcount']) ? '5' : $instance['postcount'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $order = isset($instance['order']) ? $instance['order'] : 'date';
        $width = isset($instance['width']) ? $instance['width'] : 'large';
        $layout = isset($instance['layout']) ? $instance['layout'] : 'layout1';
        $excerpt_length = empty($instance['excerpt_length']) ? '175' : $instance['excerpt_length'];
        $sticky = isset($instance['sticky']) ? $instance['sticky'] : 1;
        $excerpt = isset($instance['excerpt']) ? $instance['excerpt'] : 0;
        if ($cats) {
            $category = $category . ', ' . $cats;
        }
        echo $before_widget;
        ?>
        <section id="slider-<?php 
        echo rand(1, 9999);
        ?>
" class="flexslider <?php 
        echo 'slider-' . $width . ' slider-' . $layout;
        ?>
">
			<ul class="slides"><?php 
        $args = array('posts_per_page' => $postcount, 'cat' => $category, 'tag' => $tags, 'offset' => $offset, 'orderby' => $order, 'ignore_sticky_posts' => $sticky);
        $slider = new WP_query($args);
        while ($slider->have_posts()) {
            $slider->the_post();
            ?>
				<li>
				<article class="slide-wrap">
					<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><?php 
            if (has_post_thumbnail()) {
                if ($width == 'large') {
                    the_post_thumbnail('slider');
                } else {
                    the_post_thumbnail('content');
                }
            } else {
                if ($width == 'large') {
                    echo '<img class="mh-image-placeholder" src="' . get_template_directory_uri() . '/images/noimage_940x400.png' . '" alt="No Picture" />';
                } else {
                    echo '<img class="mh-image-placeholder" src="' . get_template_directory_uri() . '/images/noimage_620x264.png' . '" alt="No Picture" />';
                }
            }
            ?>
					</a>
					<div class="slide-caption">
						<div class="slide-data">
							<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><h2 class="slide-title"><?php 
            the_title();
            ?>
</h2></a>
							<?php 
            if ($excerpt == 0) {
                ?>
								<?php 
                mh_excerpt($excerpt_length);
                ?>
							<?php 
            }
            ?>
						</div>
					</div>
				</article>
				</li><?php 
        }
        wp_reset_postdata();
        ?>
			</ul>
		</section><?php 
        echo $after_widget;
    }
コード例 #5
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $postcount = empty($instance['postcount']) ? '5' : $instance['postcount'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $sticky = isset($instance['sticky']) ? $instance['sticky'] : 1;
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
        <ul class="cp-widget clearfix"> <?php 
        $args = array('posts_per_page' => $postcount, 'offset' => $offset, 'cat' => $category, 'ignore_sticky_posts' => $sticky);
        $counter = 1;
        $widget_loop = new WP_Query($args);
        while ($widget_loop->have_posts()) {
            $widget_loop->the_post();
            if ($counter == 1) {
                ?>
			<li class="cp-wrap clearfix">
				<div class="cp-thumb-xl"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('cp_large');
                } else {
                    echo '<img src="' . get_template_directory_uri() . '/images/noimage_cp_large.png' . '" alt="No Picture" />';
                }
                ?>
</a></div>
				<div class="cp-data">
					<h3 class="cp-xl-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                the_title();
                ?>
</a></h3>
					<p class="meta">
						<?php 
                $post_date = get_the_date();
                ?>
						<?php 
                echo $post_date . ' | ';
                ?>
						<?php 
                mh_comment_count();
                ?>
					</p>
				</div>
				<?php 
                mh_excerpt();
                ?>
			</li><?php 
            } else {
                ?>
			<li class="cp-wrap cp-small clearfix">
				<div class="cp-thumb"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('cp_small');
                } else {
                    echo '<img src="' . get_template_directory_uri() . '/images/noimage_70x53.png' . '" alt="No Picture" />';
                }
                ?>
</a></div>
				<div class="cp-data">
					<p class="cp-widget-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                the_title();
                ?>
</a></p>
					<p class="meta"><?php 
                comments_number(__('0 Comments', 'mh-corporate-basic'), __('1 Comment', 'mh-corporate-basic'), __('% Comments', 'mh-corporate-basic'));
                ?>
</p>
				</div>
			</li><?php 
            }
            $counter++;
        }
        wp_reset_postdata();
        ?>
        </ul><?php 
        echo $after_widget;
    }
コード例 #6
0
ファイル: mh-spotlight.php プロジェクト: Gabriel-07/site
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('In the spotlight', 'mh') : $instance['title'], $instance, $this->id_base);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $tags = empty($instance['tags']) ? '' : $instance['tags'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $order = isset($instance['order']) ? $instance['order'] : 'date';
        $width = isset($instance['width']) ? $instance['width'] : 'normal_sl';
        $excerpt_length = empty($instance['excerpt_length']) ? '175' : $instance['excerpt_length'];
        $excerpt = isset($instance['excerpt']) ? $instance['excerpt'] : 0;
        $meta = isset($instance['meta']) ? $instance['meta'] : 0;
        echo $before_widget;
        ?>
		<article class="spotlight"><?php 
        $args = array('posts_per_page' => 1, 'cat' => $category, 'tag' => $tags, 'offset' => $offset, 'orderby' => $order, 'ignore_sticky_posts' => 1);
        $spotlight_loop = new WP_Query($args);
        while ($spotlight_loop->have_posts()) {
            $spotlight_loop->the_post();
            ?>
			<div class="sl-caption"><?php 
            echo $title;
            ?>
</div>	
			<div class="sl-thumb">
				<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            if (has_post_thumbnail()) {
                if ($width == 'normal_sl') {
                    the_post_thumbnail('spotlight');
                } else {
                    the_post_thumbnail('slider');
                }
            } else {
                if ($width == 'normal_sl') {
                    echo '<img src="' . get_template_directory_uri() . '/images/noimage_580x326.png' . '" alt="No Picture" />';
                } else {
                    echo '<img src="' . get_template_directory_uri() . '/images/noimage_940x400.png' . '" alt="No Picture" />';
                }
            }
            ?>
				</a>
			</div>
			<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><h2 class="sl-title"><?php 
            the_title();
            ?>
</h2></a>
			<?php 
            if ($meta == 0) {
                ?>
				<p class="meta"><?php 
                _e('by ', 'mh') . the_author() . _e(' in ', 'mh');
                $category = get_the_category();
                echo $category[0]->cat_name;
                ?>
</p>
			<?php 
            }
            ?>
			<?php 
            if ($excerpt == 0) {
                ?>
				<?php 
                mh_excerpt($excerpt_length);
                ?>
			<?php 
            }
            ?>
			<?php 
            if ($meta == 0) {
                ?>
			<p class="meta"><?php 
                comments_number(__('0 Comments', 'mh'), __('1 Comment', 'mh'), __('% Comments', 'mh'));
                ?>
</p>
			<?php 
            }
        }
        wp_reset_postdata();
        ?>
		
		</article><?php 
        echo $after_widget;
    }
コード例 #7
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $cats = empty($instance['cats']) ? '' : $instance['cats'];
        $tags = empty($instance['tags']) ? '' : $instance['tags'];
        $postcount = empty($instance['postcount']) ? '5' : $instance['postcount'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $order = isset($instance['order']) ? $instance['order'] : 'date';
        $excerpt = isset($instance['excerpt']) ? $instance['excerpt'] : 'none';
        $excerpt_length = empty($instance['excerpt_length']) ? '175' : $instance['excerpt_length'];
        $link = empty($instance['link']) ? '' : $instance['link'];
        $thumbnails = isset($instance['thumbnails']) ? $instance['thumbnails'] : 'show_thumbs';
        $sticky = isset($instance['sticky']) ? $instance['sticky'] : 1;
        $date = isset($instance['date']) ? $instance['date'] : 0;
        $comments = isset($instance['comments']) ? $instance['comments'] : 0;
        if ($link) {
            $before_title = $before_title . '<a href="' . esc_url($link) . '" class="widget-title-link">';
            $after_title = '</a>' . $after_title;
        } elseif ($category) {
            $cat_url = get_category_link($category);
            $before_title = $before_title . '<a href="' . esc_url($cat_url) . '" class="widget-title-link">';
            $after_title = '</a>' . $after_title;
        }
        if ($cats) {
            $category = $category . ', ' . $cats;
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . esc_attr($title) . $after_title;
        }
        $thumbnails == 'show_thumbs' || $thumbnails == 'hide_large' ? $cp_no_image = '' : ($cp_no_image = ' cp-no-image');
        ?>
        <ul class="cp-widget<?php 
        echo $cp_no_image;
        ?>
 clearfix"> <?php 
        $args = array('posts_per_page' => $postcount, 'offset' => $offset, 'cat' => $category, 'tag' => $tags, 'orderby' => $order, 'ignore_sticky_posts' => $sticky);
        $counter = 1;
        $widget_loop = new WP_Query($args);
        while ($widget_loop->have_posts()) {
            $widget_loop->the_post();
            if ($counter == 1 && $excerpt == 'first' || $excerpt == 'all') {
                ?>
			<li class="cp-wrap cp-large clearfix">
				<?php 
                if ($thumbnails == 'show_thumbs' || $thumbnails == 'hide_small') {
                    ?>
					<div class="cp-thumb-xl"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title_attribute();
                    ?>
"><?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('cp_large');
                    } else {
                        echo '<img class="mh-image-placeholder" src="' . get_template_directory_uri() . '/images/noimage_300x225.png' . '" alt="No Picture" />';
                    }
                    ?>
</a></div>
				<?php 
                }
                ?>
				<div class="cp-data">
					<h3 class="cp-xl-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                the_title();
                ?>
</a></h3>
					<?php 
                if ($date == 0 || $comments == 0) {
                    ?>
						<p class="meta"><?php 
                    if ($date == 0) {
                        $post_date = get_the_date();
                        echo $post_date;
                    }
                    if ($date == 0 && $comments == 0) {
                        echo ' // ';
                    }
                    if ($comments == 0) {
                        mh_comment_count();
                    }
                    ?>
						</p>
					<?php 
                }
                ?>
				</div>
				<?php 
                mh_excerpt($excerpt_length);
                ?>
			</li><?php 
            } else {
                ?>
			<li class="cp-wrap cp-small clearfix">
				<?php 
                if ($thumbnails == 'show_thumbs' || $thumbnails == 'hide_large') {
                    ?>
					<div class="cp-thumb"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title_attribute();
                    ?>
"><?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('cp_small');
                    } else {
                        echo '<img class="mh-image-placeholder" src="' . get_template_directory_uri() . '/images/noimage_cp_small.png' . '" alt="No Picture" />';
                    }
                    ?>
</a></div>
				<?php 
                }
                ?>
				<div class="cp-data">
					<p class="cp-widget-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                the_title();
                ?>
</a></p>
					<?php 
                if ($comments == 0) {
                    ?>
						<p class="meta"><?php 
                    mh_comment_count();
                    ?>
</p>
					<?php 
                }
                ?>
				</div>
			</li><?php 
            }
            $counter++;
        }
        wp_reset_postdata();
        ?>
        </ul><?php 
        echo $after_widget;
    }
コード例 #8
0
        } else {
            echo '<img src="' . get_template_directory_uri() . '/images/noimage_620x264.png' . '" alt="No Picture" />';
        }
    }
    ?>
					</a>
					<div class="slide-caption">
						<div class="slide-data">
							<a href="<?php 
    the_permalink();
    ?>
" title="<?php 
    the_title();
    ?>
"><h2 class="slide-title"><?php 
    the_title();
    ?>
</h2></a>
							<?php 
    mh_excerpt();
    ?>
						</div>
					</div>
				</article>
			</li>
		<?php 
}
?>
		</ul>
	</div>
</div>
コード例 #9
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $link = empty($instance['link']) ? '' : $instance['link'];
        $pages = empty($instance['pages']) ? '' : $instance['pages'];
        $excerpt = isset($instance['excerpt']) ? $instance['excerpt'] : 'none';
        $excerpt_length = empty($instance['excerpt_length']) ? '175' : $instance['excerpt_length'];
        $thumbnails = isset($instance['thumbnails']) ? $instance['thumbnails'] : 'show_thumbs';
        if ($link) {
            $before_title = $before_title . '<a href="' . esc_url($link) . '" class="widget-title-link">';
            $after_title = '</a>' . $after_title;
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
        <ul class="cp-widget clearfix"> <?php 
        $include_ids = explode(',', $pages);
        $args = array('post_type' => 'page', 'post__in' => $include_ids, 'orderby' => 'post__in');
        $counter = 1;
        $widget_loop = new WP_Query($args);
        while ($widget_loop->have_posts()) {
            $widget_loop->the_post();
            if ($counter == 1 && $excerpt == 'first' || $excerpt == 'all') {
                ?>
			<li class="cp-wrap cp-large clearfix">
				<?php 
                if ($thumbnails == 'show_thumbs' || $thumbnails == 'hide_small') {
                    ?>
					<div class="cp-thumb-xl"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('cp_large');
                    } else {
                        echo '<img src="' . get_template_directory_uri() . '/images/noimage_300x225.png' . '" alt="No Picture" />';
                    }
                    ?>
</a></div>
				<?php 
                }
                ?>
				<div class="cp-data">
					<h3 class="cp-xl-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
"><?php 
                the_title();
                ?>
</a></h3>
				</div>
				<?php 
                mh_excerpt($excerpt_length);
                ?>
			</li><?php 
            } else {
                ?>
			<?php 
                $thumbnails == 'show_thumbs' || $thumbnails == 'hide_large' ? $cp_no_image = '' : ($cp_no_image = ' cp-no-image');
                ?>
			<li class="cp-wrap cp-small<?php 
                echo $cp_no_image;
                ?>
 clearfix">
				<?php 
                if ($thumbnails == 'show_thumbs' || $thumbnails == 'hide_large') {
                    ?>
					<div class="cp-thumb"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('cp_small');
                    } else {
                        echo '<img src="' . get_template_directory_uri() . '/images/noimage_cp_small.png' . '" alt="No Picture" />';
                    }
                    ?>
</a></div>
				<?php 
                }
                ?>
				<div class="cp-data">
					<p class="cp-widget-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
"><?php 
                the_title();
                ?>
</a></p>
				</div>
			</li><?php 
            }
            $counter++;
        }
        wp_reset_postdata();
        ?>
        </ul><?php 
        echo $after_widget;
    }
コード例 #10
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $cats = empty($instance['cats']) ? '' : $instance['cats'];
        $tags = empty($instance['tags']) ? '' : $instance['tags'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $order = isset($instance['order']) ? $instance['order'] : 'date';
        $width = isset($instance['width']) ? $instance['width'] : 'normal_sl';
        $excerpt_length = empty($instance['excerpt_length']) ? '175' : $instance['excerpt_length'];
        $excerpt = isset($instance['excerpt']) ? $instance['excerpt'] : 0;
        $meta = isset($instance['meta']) ? $instance['meta'] : 0;
        $date = isset($instance['date']) ? $instance['date'] : 0;
        $comments = isset($instance['comments']) ? $instance['comments'] : 0;
        if ($cats) {
            $category = $category . ', ' . $cats;
        }
        echo $before_widget;
        ?>
		<article class="spotlight"><?php 
        $args = array('posts_per_page' => 1, 'cat' => $category, 'tag' => $tags, 'offset' => $offset, 'orderby' => $order, 'ignore_sticky_posts' => 1);
        $spotlight_loop = new WP_Query($args);
        while ($spotlight_loop->have_posts()) {
            $spotlight_loop->the_post();
            ?>
			<?php 
            if ($title) {
                ?>
				<div class="sl-caption"><?php 
                echo esc_attr($title);
                ?>
</div>
			<?php 
            }
            ?>
			<div class="sl-thumb">
				<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><?php 
            if (has_post_thumbnail()) {
                if ($width == 'normal_sl') {
                    the_post_thumbnail('spotlight');
                } else {
                    the_post_thumbnail('slider');
                }
            } else {
                if ($width == 'normal_sl') {
                    echo '<img class="mh-image-placeholder" src="' . get_template_directory_uri() . '/images/noimage_580x326.png' . '" alt="No Picture" />';
                } else {
                    echo '<img class="mh-image-placeholder" src="' . get_template_directory_uri() . '/images/noimage_940x400.png' . '" alt="No Picture" />';
                }
            }
            ?>
				</a>
			</div>
			<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><h2 class="sl-title"><?php 
            the_title();
            ?>
</h2></a>
			<?php 
            if ($meta == 0) {
                ?>
				<?php 
                if ($date == 0 || $comments == 0) {
                    ?>
					<p class="meta"><?php 
                    if ($date == 0) {
                        $post_date = get_the_date();
                        echo $post_date;
                    }
                    if ($date == 0 && $comments == 0) {
                        echo ' // ';
                    }
                    if ($comments == 0) {
                        mh_comment_count();
                    }
                    ?>
					</p>
				<?php 
                }
                ?>
			<?php 
            }
            ?>
			<?php 
            if ($excerpt == 0) {
                ?>
				<?php 
                mh_excerpt($excerpt_length);
                ?>
			<?php 
            }
        }
        wp_reset_postdata();
        ?>
		</article><?php 
        echo $after_widget;
    }
コード例 #11
0
    function widget($args, $instance)
    {
        extract($args);
        global $post;
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $postcount = empty($instance['postcount']) ? '5' : $instance['postcount'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $excerpt_length = empty($instance['excerpt_length']) ? '110' : $instance['excerpt_length'];
        $sticky = isset($instance['sticky']) ? $instance['sticky'] : 0;
        if ($category) {
            $cat_url = get_category_link($category);
            $before_title = $before_title . '<a href="' . esc_url($cat_url) . '" class="widget-title-link">';
            $after_title = '</a>' . $after_title;
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
        <div class="cp-widget clearfix"> <?php 
        $args = array('posts_per_page' => $postcount, 'offset' => $offset, 'cat' => $category, 'ignore_sticky_posts' => $sticky);
        $counter = 1;
        $widget_loop = new WP_Query($args);
        while ($widget_loop->have_posts()) {
            $widget_loop->the_post();
            if ($counter == 1) {
                ?>
				<div class="cp-widget-item cp-large cp-count-<?php 
                echo esc_attr($postcount);
                ?>
">
					<div class="cp-large-thumb"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('featured');
                } else {
                    echo '<img src="' . get_template_directory_uri() . '/images/noimage_featured.png' . '" alt="No Picture" />';
                }
                ?>
</a></div>
					<div class="meta clearfix">
						<span class="meta-date"><?php 
                $post_date = get_the_date();
                echo $post_date;
                ?>
</span>
						<span class="meta-comments"><i class="fa fa-comment-o"></i><?php 
                comments_number('0', '1', '%');
                ?>
</span>
					</div>
					<h3 class="cp-large-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                the_title();
                ?>
</a></h3>
					<?php 
                mh_excerpt($excerpt_length);
                ?>
				</div>
				<ul class="cp-list"><?php 
            } else {
                ?>
					<li class="cp-widget-item cp-list-item clearfix">
						<div class="cp-small-thumb"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('cp_small');
                } else {
                    echo '<img src="' . get_template_directory_uri() . '/images/noimage_cp_small.png' . '" alt="No Picture" />';
                }
                ?>
</a></div>
						<div class="meta"><?php 
                $post_date = get_the_date();
                echo $post_date;
                ?>
</div>
						<p class="cp-small-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                the_title();
                ?>
</a></p>
					</li> <?php 
            }
            $counter++;
        }
        wp_reset_postdata();
        ?>
        	</ul>
        </div><?php 
        echo $after_widget;
    }
コード例 #12
0
ファイル: mh-custom-posts.php プロジェクト: Gabriel-07/site
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $tags = empty($instance['tags']) ? '' : $instance['tags'];
        $postcount = empty($instance['postcount']) ? '5' : $instance['postcount'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $order = isset($instance['order']) ? $instance['order'] : 'date';
        $excerpt = isset($instance['excerpt']) ? $instance['excerpt'] : 'none';
        $excerpt_length = empty($instance['excerpt_length']) ? '175' : $instance['excerpt_length'];
        $sticky = isset($instance['sticky']) ? $instance['sticky'] : 0;
        $meta = isset($instance['meta']) ? $instance['meta'] : 0;
        $images = isset($instance['images']) ? $instance['images'] : 0;
        if ($category) {
            $cat_url = get_category_link($category);
            $before_title = $before_title . '<a href="' . esc_url($cat_url) . '" class="widget-title-link">';
            $after_title = '</a>' . $after_title;
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
  
        <ul class="cp-widget clearfix"> <?php 
        $args = array('posts_per_page' => $postcount, 'offset' => $offset, 'cat' => $category, 'tag' => $tags, 'orderby' => $order, 'ignore_sticky_posts' => $sticky);
        $counter = 1;
        $widget_loop = new WP_Query($args);
        while ($widget_loop->have_posts()) {
            $widget_loop->the_post();
            if ($counter == 1 && $excerpt == 'first' || $excerpt == 'all') {
                ?>
			<li class="cp-wrap clearfix">
				<?php 
                if ($images == 0) {
                    ?>
					<div class="cp-thumb-xl"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('cp_large');
                    } else {
                        echo '<img src="' . get_template_directory_uri() . '/images/noimage_300x225.png' . '" alt="No Picture" />';
                    }
                    ?>
</a></div>
				<?php 
                }
                ?>
				<div class="cp-data">
					<h3 class="cp-xl-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
"><?php 
                the_title();
                ?>
</a></h3>
					<?php 
                if ($meta == 0) {
                    ?>
						<p class="meta"><?php 
                    $date = get_the_date();
                    echo $date;
                    ?>
 // <?php 
                    comments_number(__('0 Comments', 'mh'), __('1 Comment', 'mh'), __('% Comments', 'mh'));
                    ?>
</p>	
					<?php 
                }
                ?>
					
				</div>
				<?php 
                mh_excerpt($excerpt_length);
                ?>
			</li><?php 
            } else {
                ?>
			<li class="cp-wrap cp-small clearfix">
				<?php 
                if ($images == 0) {
                    ?>
 					
					<div class="cp-thumb"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('cp_small');
                    } else {
                        echo '<img src="' . get_template_directory_uri() . '/images/noimage-cp_small.png' . '" alt="No Picture" />';
                    }
                    ?>
</a></div>
				<?php 
                }
                ?>
				<div class="cp-data">
					<p class="cp-widget-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
"><?php 
                the_title();
                ?>
</a></p>
					<?php 
                if ($meta == 0) {
                    ?>
						<p class="meta"><?php 
                    comments_number(__('0 Comments', 'mh'), __('1 Comment', 'mh'), __('% Comments', 'mh'));
                    ?>
</p>
					<?php 
                }
                ?>
					
				</div>									
			</li><?php 
            }
            $counter++;
        }
        wp_reset_postdata();
        ?>
        </ul><?php 
        echo $after_widget;
    }
コード例 #13
0
    function widget($args, $instance)
    {
        extract($args);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $postcount = empty($instance['postcount']) ? '5' : $instance['postcount'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $sticky = isset($instance['sticky']) ? $instance['sticky'] : 1;
        echo $before_widget;
        ?>
        <section id="slider-<?php 
        echo rand(1, 9999);
        ?>
" class="flexslider">
			<ul class="slides"><?php 
        $args = array('posts_per_page' => $postcount, 'cat' => $category, 'offset' => $offset, 'ignore_sticky_posts' => $sticky);
        $slider = new WP_query($args);
        while ($slider->have_posts()) {
            $slider->the_post();
            ?>
				<li>
				<article class="slide-wrap">
					<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
">
						<?php 
            if (has_post_thumbnail()) {
                the_post_thumbnail('slider');
            } else {
                echo '<img src="' . get_template_directory_uri() . '/images/noimage_940x400.png' . '" alt="No Picture" />';
            }
            ?>
					</a>
					<div class="slide-caption">
						<div class="slide-data">
							<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><h2 class="slide-title"><?php 
            the_title();
            ?>
</h2></a>
							<div class="slide-excerpt"><?php 
            mh_excerpt();
            ?>
</div>
						</div>
					</div>
				</article>
				</li><?php 
        }
        wp_reset_postdata();
        ?>
			</ul>
		</section><?php 
        echo $after_widget;
    }