function redwaves_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'); $related_posts_excerpt = get_theme_mod('related_posts_excerpt', '10'); if ($related_posts == true && 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()) { ?> <div id="related_posts" class="related-posts"><h3><?php _e("Related Posts", "redwaves-lite"); ?> </h3><ul> <?php while ($my_query->have_posts()) { $my_query->the_post(); ?> <li> <div class="horizontal-container"> <div class="relatedthumb"> <a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?> "> <img width="120" height="120" src="<?php echo redwaves_get_thumbnail('small'); ?> " class="attachment-featured wp-post-image" alt="<?php the_title_attribute(); ?> "> <div class="post-format"><i class="fa fa-file-text"></i></div> </a> </div> <div class="post-data-container"> <div class="post-title"> <h4><a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?> "><?php the_title(); ?> </a></h4> </div> <div class="post-info"> <div class="meta-info"> <?php redwaves_posted(); redwaves_entry_comments(); ?> </div> </div> <div class="widget-post-excerpt"> <?php if ($related_posts_excerpt && intval($related_posts_excerpt) > 0 && intval($related_posts_excerpt) <= 40) { echo redwaves_excerpt($related_posts_excerpt); } ?> </div> </div> </div> </li> <?php } echo '</ul></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()) { ?> <div id="related_posts" class="related-posts"><h3><?php _e("Related Posts", "redwaves-lite"); ?> </h3><ul> <?php while ($my_query->have_posts()) { $my_query->the_post(); ?> <li> <div class="horizontal-container"> <div class="relatedthumb"> <a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?> "> <img width="120" height="120" src="<?php echo redwaves_get_thumbnail('small'); ?> " class="attachment-featured wp-post-image" alt="<?php the_title_attribute(); ?> "> <div class="post-format"><i class="fa fa-file-text"></i></div> </a> </div> <div class="post-data-container"> <div class="post-title"> <h4><a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?> "><?php the_title(); ?> </a></h4> </div> <div class="post-info"> <div class="meta-info"> <?php redwaves_posted(); redwaves_entry_comments(); ?> </div> </div> <div class="widget-post-excerpt"> <?php if ($related_posts_excerpt && intval($related_posts_excerpt) > 0 && intval($related_posts_excerpt) <= 40) { echo redwaves_excerpt($related_posts_excerpt); } ?> </div> </div> </div> </li> <?php } echo '</ul></div>'; } } $post = $orig_post; wp_reset_query(); } } }
public function get_cat_posts($qty, $comment_num, $date, $show_thumb, $show_excerpt, $excerpt_length) { // Custom CSS Output if ($show_thumb == 1) { $css = 'padding-left:90px;'; } 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 redwaves_get_thumbnail('tiny'); ?> " class="attachment-featured wp-post-image" alt="<?php the_title_attribute(); ?> "> <div class="post-format"><i class="fa fa-file-text"></i></div> </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 || $comment_num == 1) { ?> <div class="widget-post-info"> <?php if ($date == 1) { redwaves_posted(); } ?> <?php if ($comment_num == 1) { redwaves_entry_comments(); } ?> </div><!--end .widget-post-info--> <?php } ?> <?php if ($show_excerpt == 1) { ?> <div class="widget-post-excerpt"> <?php echo redwaves_excerpt($excerpt_length); ?> </div> <?php } ?> </div> <?php echo '</li>'; ?> <?php } wp_reset_postdata(); echo '</ul></div>' . "\r\n"; }
?> " <?php post_class('post-box big-post-box'); ?> > <div class="post-data-container"> <div class="single-featured"> <a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?> "> <img width="666" height="333" src="<?php echo redwaves_get_thumbnail('big'); ?> " class="attachment-featured wp-post-image" alt="<?php the_title_attribute(); ?> "> <div class="post-format"><i class="fa fa-file-text"></i></div> </a> </div> <header class="entry-header"> <div class="entry-meta post-info"> <?php the_title(sprintf('<h2 class="entry-title post-title"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>'); $archives_post_meta = get_theme_mod('archives_post_meta', '1'); if ($archives_post_meta) { redwaves_entry_category();
public function get_popular_posts($qty, $comment_num, $date, $days, $show_thumb, $show_excerpt, $excerpt_length) { // Custom CSS Output if ($show_thumb == 1) { $css = 'padding-left:90px;'; } 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 redwaves_get_thumbnail('tiny'); ?> " class="attachment-featured wp-post-image" alt="<?php the_title_attribute(); ?> "> <div class="post-format"><i class="fa fa-file-text"></i></div> </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 || $comment_num == 1) { ?> <div class="widget-post-info"> <?php if ($date == 1) { redwaves_posted(); } ?> <?php if ($comment_num == 1) { redwaves_entry_comments(); } ?> </div> <!--end .post-info--> <?php } ?> <?php if ($show_excerpt == 1) { ?> <div class="widget-post-excerpt"> <?php echo redwaves_excerpt($excerpt_length); ?> </div> <?php } ?> </div> <?php } wp_reset_postdata(); echo '</ul></div>' . "\r\n"; }