Exemplo n.º 1
0
    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 = 'sociallyviral_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 = 'sociallyviral_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 
                echo esc_url(get_the_permalink());
                ?>
" title="<?php 
                echo esc_attr(get_the_title());
                ?>
">
						<?php 
                echo '<div class="featured-thumbnail">';
                if (has_post_thumbnail()) {
                    the_post_thumbnail($thumbnail, array('title' => ''));
                } else {
                    ?>
							<img src="<?php 
                    echo sociallyviral_get_thumbnail_url($thumbnail == 'sociallyviral_widgetthumb' ? 'sociallyviral_widgetthumb' : 'sociallyviral_widgetfull');
                    ?>
" alt="<?php 
                    the_title();
                    ?>
" />
						<?php 
                }
                echo '</div>';
                ?>
					</a>
				</div>
				<?php 
            }
            ?>
				<div class="post-data">
					<div class="post-data-container">
						<div class="post-title">
							<a href="<?php 
            echo esc_url(get_the_permalink());
            ?>
" title="<?php 
            echo esc_attr(get_the_title());
            ?>
"><?php 
            echo esc_html(sociallyviral_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="icon-clock"></i> <?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
							<?php 
                }
                ?>
							<?php 
                if ($comment_num == 1) {
                    ?>
							<span class="thecomment"><i class="icon-chat"></i> <?php 
                    echo comments_number('0', '1', '%');
                    ?>
</span>
							<?php 
                }
                ?>
						</div> <!--.post-info-->
						<?php 
            }
            ?>
						<?php 
            if ($show_excerpt == 1) {
                ?>
						<div class="post-excerpt">
							<?php 
                echo sociallyviral_excerpt($excerpt_length);
                ?>
						</div>
						<?php 
            }
            ?>
					</div>
				</div>
			<?php 
            echo $close_li_item;
            ?>
		<?php 
        }
        wp_reset_postdata();
        echo '</ul>' . "\r\n";
    }
Exemplo n.º 2
0
 function sociallyviral_excerpt($limit = 40)
 {
     return esc_html(sociallyviral_truncate(get_the_excerpt(), $limit, 'words'));
 }