Example #1
0
 function ktz_relpost()
 {
     if (ot_get_option('ktz_active_related') == 'yes') {
         global $post;
         $orig_post = $post;
         if (ot_get_option('ktz_taxonomy_relpost') == 'tags') {
             $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' => 4, 'ignore_sticky_posts' => 1);
             }
         } else {
             $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' => 3, 'ignore_sticky_posts' => 1);
             }
         }
         if (!isset($args)) {
             $args = '';
         }
         $ktz_query = new WP_Query($args);
         if ($ktz_query->have_posts()) {
             echo '<h2 class="related-title"><span>' . __('Related Post', ktz_theme_textdomain) . ' "' . get_the_title() . '"</span></h2>';
             echo '<div class="ktz-related-post row">';
             while ($ktz_query->have_posts()) {
                 $ktz_query->the_post();
                 global $post;
                 echo '<div class="col-md-4">';
                 echo ktz_featured_just_img(250, 150);
                 echo '<div class="ktz-wrap-relpost">';
                 echo '<div class="ktz_title_related">';
                 echo ktz_posted_title_a();
                 echo '</div>';
                 echo '</div>';
                 echo '</div>';
             }
             echo '</div>';
         } else {
             echo '<div class="no-post">No related post!</div>';
         }
         $post = $orig_post;
         wp_reset_query();
     }
 }
Example #2
0
    the_ID();
    ?>
 -->
			<?php 
}
// end of the loop.
?>
		</section>

			<?php 
$args = array('orderby' => 'rand', 'post_type' => 'attachment', 'post_status' => 'inherit', 'posts_per_page' => 4);
$query = new WP_Query($args);
echo '<h3 class="related-title"><span>' . __('Random attachment', ktz_theme_textdomain) . ' ' . get_the_title() . '</span></h3>';
echo '<div class="row">';
if ($query->have_posts()) {
    while ($query->have_posts()) {
        $query->the_post();
        echo '<div class="col-md-3 ktz-random-attachment">';
        echo '<a href="' . get_permalink() . '" title="' . get_the_title() . '">';
        echo ktz_featured_just_img(245, 150);
        echo '</a>';
        echo '</div>';
    }
    wp_reset_postdata();
}
echo '</div>';
?>
		</div>
	</section>
<?php 
get_footer();
Example #3
0
 function widget($args, $instance)
 {
     $cache = wp_cache_get('widget_recent_posts', 'widget');
     if (!is_array($cache)) {
         $cache = array();
     }
     if (isset($cache[$args['widget_id']])) {
         echo $cache[$args['widget_id']];
         return;
     }
     ob_start();
     extract($args);
     $style_latest = empty($instance['style_latest']) ? 'list' : $instance['style_latest'];
     $cats = empty($instance['cats']) ? '' : $instance['cats'];
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
     $number = empty($instance['number']) ? '5' : $instance['number'];
     $ktzrecent = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'cat' => $cats));
     if ($ktzrecent->have_posts()) {
         global $post;
         echo $before_widget;
         if ($title) {
             if ($title != '') {
                 echo '<h4 class="widget-title';
                 if ($cats != '') {
                     $cat_array = get_category($cats);
                     echo ' ' . $cat_array->slug;
                 }
                 echo '">';
                 echo '<span class="ktz-blocktitle">' . $title . '</span>';
                 echo '</h4>';
             } else {
                 echo '';
             }
         }
         if ($style_latest == "list") {
             echo '<ul class="ktz-recent-list ktz-widgetcolor';
             if ($cats != '') {
                 $cat_array = get_category($cats);
                 echo ' ' . $cat_array->slug;
             }
             echo '">';
             while ($ktzrecent->have_posts()) {
                 $ktzrecent->the_post();
                 echo '<li class="clearfix">';
                 echo ktz_featured_img(40, 40);
                 echo ktz_posted_title_a();
                 echo '</li>';
             }
             echo '</ul>';
         } elseif ($style_latest == "box") {
             echo '<div class="ktz-gallery ktz-boxgrid"><ul>';
             while ($ktzrecent->have_posts()) {
                 $ktzrecent->the_post();
                 echo '<li><a href="' . get_permalink() . '" title="' . get_the_title() . '">';
                 echo ktz_featured_just_img(120, 120);
                 echo '</a></li>';
             }
             echo '</ul></div>';
         } else {
             echo '<ul class="ktz-widgetcolor ktz_widget_default';
             if ($cats != '') {
                 $cat_array = get_category($cats);
                 echo ' ' . $cat_array->slug;
             }
             echo '">';
             while ($ktzrecent->have_posts()) {
                 $ktzrecent->the_post();
                 echo '<li>';
                 echo ktz_posted_title_a();
                 echo '</li>';
             }
             echo '</ul>';
         }
         wp_reset_query();
     }
     echo $after_widget;
     $cache[$args['widget_id']] = ob_get_flush();
     wp_cache_add('widget_recent_posts', $cache, 'widget');
 }