Beispiel #1
0
    public function get_author_posts($qty, $title_length, $comment_num, $date, $show_thumb7, $box_layout, $show_excerpt, $excerpt_length)
    {
        $no_image = $show_thumb7 ? '' : ' no-thumb';
        if ('horizontal-small' === $box_layout) {
            $thumbnail = 'widgetthumb';
            $open_li_item = '<li class="post-box horizontal-small horizontal-container' . $no_image . '"><div class="horizontal-container-inner">';
            $close_li_item = '</div></li>';
        } else {
            $thumbnail = 'widgetfull';
            $open_li_item = '<li class="post-box vertical-small' . $no_image . '">';
            $close_li_item = '</li>';
        }
        global $post;
        $thePostID = $post->ID;
        $posts = new WP_Query(array('author' => $post->post_author, 'post__not_in' => array($thePostID), 'posts_per_page' => $qty, 'orderby' => 'rand'));
        echo '<ul class="author-posts-widget">';
        while ($posts->have_posts()) {
            $posts->the_post();
            ?>
			<?php 
            echo $open_li_item;
            ?>
				<?php 
            if ($show_thumb7 == 1) {
                ?>
				<div class="post-img">
					<a rel="nofollow" href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
						<?php 
                the_post_thumbnail($thumbnail, array('title' => ''));
                ?>
					</a>
				</div>
				<?php 
            }
            ?>
				<div class="post-data">
					<div class="post-data-container">
						<div class="post-title">
							<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            echo mts_truncate(get_the_title(), $title_length, 'words');
            ?>
</a>
						</div>
						<?php 
            if ($date == 1 || $comment_num == 1 || $show_excerpt == 1) {
                ?>
						<div class="post-info">
							<?php 
                if ($date == 1) {
                    ?>
								<span class="thetime updated"><i class="fa fa-clock-o"></i> <?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
							<?php 
                }
                ?>
							<?php 
                if ($comment_num == 1) {
                    ?>
								<span class="thecomment"><i class="fa fa-comments"></i> <?php 
                    echo comments_number('0', '1', '%');
                    ?>
</span>
							<?php 
                }
                ?>
							<?php 
                if ($show_excerpt == 1) {
                    ?>
								<div class="post-excerpt">
									<?php 
                    echo mts_excerpt($excerpt_length);
                    ?>
								</div>
							<?php 
                }
                ?>
						</div><!--.post-info-->
						<?php 
            }
            ?>
					</div>
				</div>
			<?php 
            echo $close_li_item;
            ?>
		<?php 
        }
        echo '</ul>' . "\r\n";
    }
Beispiel #2
0
 function mts_excerpt($limit = 40)
 {
     return mts_truncate(get_the_excerpt(), $limit, 'words');
 }
Beispiel #3
0
    public function get_popular_posts($qty, $title_length, $comment_num, $date, $days, $show_thumb3, $box_layout, $show_excerpt, $excerpt_length)
    {
        $no_image = $show_thumb3 ? '' : ' no-thumb';
        if ('horizontal-small' === $box_layout) {
            $thumbnail = 'widgetthumb';
            $open_li_item = '<li class="post-box horizontal-small horizontal-container' . $no_image . '"><div class="horizontal-container-inner">';
            $close_li_item = '</div></li>';
        } else {
            $thumbnail = 'widgetfull';
            $open_li_item = '<li class="post-box vertical-small' . $no_image . '">';
            $close_li_item = '</li>';
        }
        global $post;
        $popular_days = array();
        if ($days) {
            $popular_days = array('after' => "{$days} day ago", 'before' => 'today', 'inclusive' => true);
        }
        $popular = get_posts(array('suppress_filters' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'comment_count', 'numberposts' => $qty, 'date_query' => $popular_days));
        echo '<ul class="popular-posts">';
        foreach ($popular as $post) {
            setup_postdata($post);
            ?>
			<?php 
            echo $open_li_item;
            ?>
				<?php 
            if ($show_thumb3 == 1) {
                ?>
				<div class="post-img">
					<a rel="nofollow" href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
						<?php 
                the_post_thumbnail($thumbnail, array('title' => ''));
                ?>
					</a>
				</div>
				<?php 
            }
            ?>
				<div class="post-data">
					<div class="post-data-container">
						<div class="post-title">
							<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            echo mts_truncate(get_the_title(), $title_length, 'words');
            ?>
</a>
						</div>
						<?php 
            if ($date == 1 || $comment_num == 1 || $show_excerpt == 1) {
                ?>
						<div class="post-info">
							<?php 
                if ($date == 1) {
                    ?>
								<span class="thetime updated"><i class="fa fa-clock-o"></i> <?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
							<?php 
                }
                ?>
							<?php 
                if ($comment_num == 1) {
                    ?>
								<span class="thecomment"><i class="fa fa-comments"></i> <?php 
                    echo comments_number('0', '1', '%');
                    ?>
</span>
							<?php 
                }
                ?>
							<?php 
                if ($show_excerpt == 1) {
                    ?>
								<div class="post-excerpt">
									<?php 
                    echo mts_excerpt($excerpt_length);
                    ?>
								</div>
							<?php 
                }
                ?>
						</div> <!--end .post-info-->
						<?php 
            }
            ?>
					</div>
				</div>
			<?php 
            echo $close_li_item;
            ?>
		<?php 
        }
        wp_reset_postdata();
        echo '</ul>' . "\r\n";
    }
    public function get_cat_posts($qty, $title_length, $comment_num, $date, $show_thumb6, $box_layout, $show_excerpt, $excerpt_length)
    {
        $no_image = $show_thumb6 ? '' : ' no-thumb';
        if ('horizontal-small' === $box_layout) {
            $thumbnail = 'widgetthumb';
            $open_li_item = '<li class="post-box horizontal-small horizontal-container' . $no_image . '"><div class="horizontal-container-inner">';
            $close_li_item = '</div></li>';
        } else {
            $thumbnail = 'widgetfull';
            $open_li_item = '<li class="post-box vertical-small' . $no_image . '">';
            $close_li_item = '</li>';
        }
        global $post;
        $thePostID = $post->ID;
        $cats = get_the_category($thePostID);
        $cat_ids = array();
        foreach ($cats as $individual_cat) {
            $cat_ids[] = $individual_cat->cat_ID;
        }
        $posts = new WP_Query(array('category__in' => $cat_ids, 'post__not_in' => array($thePostID), 'posts_per_page' => $qty, 'orderby' => 'rand'));
        echo '<ul class="related-posts-widget">';
        while ($posts->have_posts()) {
            $posts->the_post();
            ?>
			<?php 
            echo $open_li_item;
            ?>
				<?php 
            if ($show_thumb6 == 1) {
                ?>
				<div class="post-img">
					<a rel="nofollow" href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
						<?php 
                the_post_thumbnail($thumbnail, array('title' => ''));
                ?>
					</a>
				</div>
				<?php 
            }
            ?>
				<div class="post-data">
					<div class="post-data-container">
						<div class="post-title">
							<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            echo mts_truncate(get_the_title(), $title_length, 'words');
            ?>
</a>
						</div>
						<?php 
            if ($date == 1 || $comment_num == 1) {
                ?>
						<div class="post-info">
							<?php 
                if ($date == 1) {
                    ?>
								<span class="thetime updated"><i class="fa fa-clock-o"></i> <?php 
                    echo human_time_diff(get_the_time('U'), current_time('timestamp')) . __(' ago', 'mythemeshop');
                    ?>
</span>
							<?php 
                }
                ?>
							<?php 
                if ($comment_num == 1) {
                    ?>
								<span class="thecomment"><i class="fa fa-comments"></i> <?php 
                    echo comments_number('0', '1', '%');
                    ?>
</span>
							<?php 
                }
                ?>
						</div> <!--end .post-info-->
						<?php 
            }
            ?>
						<?php 
            if ($show_excerpt == 1) {
                ?>
						<div class="post-excerpt">
							<?php 
                echo mts_excerpt($excerpt_length);
                ?>
						</div>
						<?php 
            }
            ?>
					</div>
				</div>
			<?php 
            echo $close_li_item;
            ?>
		<?php 
        }
        echo '</ul>' . "\r\n";
    }
    public function get_cat_posts($qty, $title_length, $comment_num, $date, $show_thumb2, $box_layout, $show_excerpt, $excerpt_length)
    {
        $no_image = $show_thumb2 ? '' : ' no-thumb';
        if ('horizontal-small' === $box_layout) {
            $thumbnail = 'widgetthumb';
            $open_li_item = '<li class="post-box horizontal-small horizontal-container' . $no_image . '"><div class="horizontal-container-inner">';
            $close_li_item = '</div></li>';
        } else {
            $thumbnail = 'widgetfull';
            $open_li_item = '<li class="post-box vertical-small' . $no_image . '">';
            $close_li_item = '</li>';
        }
        $posts = new WP_Query("orderby=date&order=DESC&posts_per_page=" . $qty);
        echo '<ul class="advanced-recent-posts">';
        while ($posts->have_posts()) {
            $posts->the_post();
            ?>
			<?php 
            echo $open_li_item;
            ?>
				<?php 
            if ($show_thumb2 == 1) {
                ?>
				<div class="post-img">
					<a rel="nofollow" href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
						<?php 
                the_post_thumbnail($thumbnail, array('title' => ''));
                ?>
					</a>
				</div>
				<?php 
            }
            ?>
				<div class="post-data">
					<div class="post-data-container">
						<div class="post-title">
							<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            echo mts_truncate(get_the_title(), $title_length, 'words');
            ?>
</a>
						</div>
						<?php 
            if ($date == 1 || $comment_num == 1) {
                ?>
						<div class="post-info">
							<?php 
                if ($date == 1) {
                    ?>
							<span class="thetime updated"><i class="fa fa-clock-o"></i> <?php 
                    echo human_time_diff(get_the_time('U'), current_time('timestamp')) . __(' ago', 'mythemeshop');
                    ?>
</span>
							<?php 
                }
                ?>
							<?php 
                if ($comment_num == 1) {
                    ?>
							<span class="thecomment"><i class="fa fa-comments"></i> <?php 
                    echo comments_number('0', '1', '%');
                    ?>
</span>
							<?php 
                }
                ?>
						</div> <!--.post-info-->
						<?php 
            }
            ?>
						<?php 
            if ($show_excerpt == 1) {
                ?>
						<div class="post-excerpt">
							<?php 
                echo mts_excerpt($excerpt_length);
                ?>
						</div>
						<?php 
            }
            ?>
					</div>
				</div>
			<?php 
            echo $close_li_item;
            ?>
		<?php 
        }
        echo '</ul>' . "\r\n";
    }