public function get_cat_posts($qty, $category, $date, $show_thumb, $show_excerpt, $excerpt_length)
    {
        // Custom CSS Output
        if ($show_thumb == 1) {
            $css = 'padding-left:80px;';
        } else {
            $css = 'padding-left:10px;';
        }
        global $post;
        $posts = new WP_Query("orderby=date&order=DESC&posts_per_page=" . ($qty - 1));
        echo '<div class="widget-container recent-posts-wrap"><ul>';
        while ($posts->have_posts()) {
            $posts->the_post();
            ?>
			<?php 
            echo '<li class="post-box horizontal-container" style="' . $css . '">';
            ?>
				<?php 
            if ($show_thumb == 1) {
                ?>
				<div class="widget-post-img">
					<a rel="nofollow" href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
						<img width="70" height="70" src="<?php 
                echo realistic_get_thumbnail('tiny');
                ?>
" class="attachment-featured wp-post-image" alt="<?php 
                the_title_attribute();
                ?>
">				
						<?php 
                $format = get_post_format($post->ID);
                realistic_post_format_icon($format);
                ?>
					</a>
				</div>
				<?php 
            }
            ?>
				
					<div class="widget-post-data">
						<h4><a rel="nofollow" href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            the_title();
            ?>
</a></h4>
						<?php 
            if ($date == 1 || $category == 1) {
                ?>
							<div class="widget-post-info">
								<?php 
                if ($date == 1) {
                    realistic_posted();
                }
                ?>
								<?php 
                if ($category == 1) {
                    _e(' in ', 'realistic');
                    $thecategory = get_the_category();
                    echo '<span class="category"><a href="' . get_category_link($thecategory[0]->term_id) . '" title="' . sprintf(__("View all posts in %s", "realistic"), $thecategory[0]->name) . '" ' . '>' . $thecategory[0]->name . '</a></span>';
                }
                ?>
                                                   
							</div><!--end .widget-post-info-->
						<?php 
            }
            ?>
						<?php 
            if ($show_excerpt == 1) {
                ?>
							<div class="widget-post-excerpt">
								<?php 
                echo realistic_excerpt($excerpt_length);
                ?>
							</div>
						<?php 
            }
            ?>
					</div>
			<?php 
            echo '</li>';
            ?>
		<?php 
        }
        wp_reset_postdata();
        echo '</ul></div>' . "\r\n";
    }
Ejemplo n.º 2
0
		<?php 
if (is_sticky()) {
    echo '<div class="featured"><i class="icon icon-star"></i></div>';
}
?>
	
		<div class="post-img mdl-cell mdl-cell--4-col-desktop mdl-cell--4-col-tablet mdl-cell--4-col-phone">
			<a href="<?php 
the_permalink();
?>
" title="<?php 
the_title_attribute();
?>
">		
				<img width="218" height="181" src="<?php 
echo realistic_get_thumbnail('featured');
?>
" class="attachment-featured wp-post-image" alt="<?php 
the_title_attribute();
?>
">
				<?php 
$format = get_post_format($post->ID);
realistic_post_format_icon($format);
?>
			</a>
		</div>
		<div class="post-data  mdl-cell mdl-cell--8-col-desktop mdl-cell--4-col-tablet mdl-cell--4-col-phone">
		
			<?php 
if (current_user_can('edit_posts')) {
Ejemplo n.º 3
0
    function realistic_related_posts()
    {
        $related_posts = get_theme_mod('related_posts', '1');
        $related_posts_number = get_theme_mod('related_posts_number', '4');
        $related_posts_query = get_theme_mod('related_posts_query', 'tags');
        if ($related_posts && intval($related_posts_number) > 0 && intval($related_posts_number) <= 6) {
            if ($related_posts_query && $related_posts_query == 'tags') {
                // Query type: Tags
                global $post;
                $orig_post = $post;
                $tags = wp_get_post_tags($post->ID);
                if ($tags) {
                    $tag_ids = array();
                    foreach ($tags as $individual_tag) {
                        $tag_ids[] = $individual_tag->term_id;
                    }
                    $args = array('tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'posts_per_page' => $related_posts_number, 'ignore_sticky_posts' => 1, 'orderby' => 'rand');
                    $my_query = new wp_query($args);
                    if ($my_query->have_posts()) {
                        ?>
							<h3 class="section-title margin-8"><?php 
                        _e("Related Posts", "realistic");
                        ?>
</h3>
							<div id="related_posts" class="related-posts mdl-grid mdl-cell mdl-cell--12-col">
								<?php 
                        while ($my_query->have_posts()) {
                            $my_query->the_post();
                            ?>
								<div class="related-item mdl-card mdl-shadow--2dp mdl-grid mdl-cell--6-col-desktop mdl-cell--4-col-tablet mdl-cell--4-col-phone">
										<div class="relatedthumb mdl-cell--4-col-desktop mdl-cell--4-col-tablet mdl-cell--2-col-phone">
											<a href="<?php 
                            the_permalink();
                            ?>
" title="<?php 
                            the_title_attribute();
                            ?>
">
												<img width="120" height="120" src="<?php 
                            echo realistic_get_thumbnail('small');
                            ?>
" class="attachment-featured wp-post-image" alt="<?php 
                            the_title_attribute();
                            ?>
">
												<?php 
                            $format = get_post_format($post->ID);
                            realistic_post_format_icon($format);
                            ?>
											</a>
										</div>
										<div class="post-data-container mdl-cell--8-col-desktop mdl-cell--4-col-tablet mdl-cell--2-col-phone">
											<h4>
												<a href="<?php 
                            the_permalink();
                            ?>
" title="<?php 
                            the_title_attribute();
                            ?>
"><?php 
                            the_title();
                            ?>
</a>
											</h4>
											<div class="post-info">
												<div class="meta-info">
													<?php 
                            realistic_posted();
                            _e(' in ', 'realistic');
                            $category = get_the_category();
                            echo '<span class="category"><a href="' . get_category_link($category[0]->term_id) . '" title="' . sprintf(__("View all posts in %s", "realistic"), $category[0]->name) . '" ' . '>' . $category[0]->name . '</a></span>';
                            ?>
												</div>
											</div>
										</div>
								</div>
							<?php 
                        }
                        echo '</div>';
                    }
                }
                $post = $orig_post;
                wp_reset_query();
            } else {
                // Query type: Categories
                global $post;
                $orig_post = $post;
                $categories = get_the_category($post->ID);
                if ($categories) {
                    $category_ids = array();
                    foreach ($categories as $individual_category) {
                        $category_ids[] = $individual_category->term_id;
                    }
                    $args = array('category__in' => $category_ids, 'post__not_in' => array($post->ID), 'posts_per_page' => $related_posts_number, 'ignore_sticky_posts' => 1, 'orderby' => 'rand');
                    $my_query = new wp_query($args);
                    if ($my_query->have_posts()) {
                        ?>
							<h3 class="section-title margin-8"><?php 
                        _e("Related Posts", "realistic");
                        ?>
</h3>
							<div id="related_posts" class="related-posts mdl-grid mdl-cell mdl-cell--12-col">
								<?php 
                        while ($my_query->have_posts()) {
                            $my_query->the_post();
                            ?>
								<div class="related-item mdl-card mdl-shadow--2dp mdl-grid mdl-cell--6-col-desktop mdl-cell--4-col-tablet mdl-cell--4-col-phone">
										<div class="relatedthumb mdl-cell--4-col-desktop mdl-cell--4-col-tablet mdl-cell--2-col-phone">
											<a href="<?php 
                            the_permalink();
                            ?>
" title="<?php 
                            the_title_attribute();
                            ?>
">
												<img width="120" height="120" src="<?php 
                            echo realistic_get_thumbnail('small');
                            ?>
" class="attachment-featured wp-post-image" alt="<?php 
                            the_title_attribute();
                            ?>
">
												<?php 
                            $format = get_post_format($post->ID);
                            realistic_post_format_icon($format);
                            ?>
											</a>
										</div>
										<div class="post-data-container mdl-cell--8-col-desktop mdl-cell--4-col-tablet mdl-cell--2-col-phone">
											<h4>
												<a href="<?php 
                            the_permalink();
                            ?>
" title="<?php 
                            the_title_attribute();
                            ?>
"><?php 
                            the_title();
                            ?>
</a>
											</h4>
											<div class="post-info">
												<div class="meta-info">
													<?php 
                            realistic_posted();
                            _e(' in ', 'realistic');
                            $category = get_the_category();
                            echo '<span class="category"><a href="' . get_category_link($category[0]->term_id) . '" title="' . sprintf(__("View all posts in %s", "realistic"), $category[0]->name) . '" ' . '>' . $category[0]->name . '</a></span>';
                            ?>
												</div>
											</div>
										</div>
								</div>
							<?php 
                        }
                        echo '</div>';
                    }
                }
                $post = $orig_post;
                wp_reset_query();
            }
        }
    }
    public function get_popular_posts($qty, $category, $date, $days, $show_thumb, $show_excerpt, $excerpt_length)
    {
        // Custom CSS Output
        if ($show_thumb == 1) {
            $css = 'padding-left:80px;';
        } else {
            $css = 'padding-left:10px;';
        }
        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 '<div class="widget-container recent-posts-wrap"><ul>';
        foreach ($popular as $post) {
            setup_postdata($post);
            ?>
			<?php 
            echo '<li class="post-box horizontal-container" style="' . $css . '">';
            ?>
				<?php 
            if ($show_thumb == 1) {
                ?>
				<div class="widget-post-img">
					<a rel="nofollow" href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
						<img width="70" height="70" src="<?php 
                echo realistic_get_thumbnail('tiny');
                ?>
" class="attachment-featured wp-post-image" alt="<?php 
                the_title_attribute();
                ?>
">				
						<?php 
                $format = get_post_format($post->ID);
                realistic_post_format_icon($format);
                ?>
					</a>
				</div>
				<?php 
            }
            ?>
					<div class="widget-post-data">
						<h4><a rel="nofollow" href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            the_title();
            ?>
</a></h4>
						<?php 
            if ($date == 1 || $category == 1) {
                ?>
							<div class="widget-post-info">
								<?php 
                if ($date == 1) {
                    realistic_posted();
                }
                ?>
								<?php 
                if ($category == 1) {
                    _e(' in ', 'realistic');
                    $thecategory = get_the_category();
                    echo '<span class="category"><a href="' . get_category_link($thecategory[0]->term_id) . '" title="' . sprintf(__("View all posts in %s", "realistic"), $thecategory[0]->name) . '" ' . '>' . $thecategory[0]->name . '</a></span>';
                }
                ?>
							</div> <!--end .post-info-->
						<?php 
            }
            ?>
						<?php 
            if ($show_excerpt == 1) {
                ?>
							<div class="widget-post-excerpt">
								<?php 
                echo realistic_excerpt($excerpt_length);
                ?>
							</div>
						<?php 
            }
            ?>
					</div>
			<?php 
        }
        wp_reset_postdata();
        echo '</ul></div>' . "\r\n";
    }