related posts wordpress without plugin

Solutions on MaxInterview for related posts wordpress without plugin by the best coders in the world

showing results for - "related posts wordpress without plugin"
Niki
08 Mar 2016
1<?php
2/**
3 * Blog Template Part for displaying single blog related posts
4 *
5 * @package Thype
6 * @subpackage Blog Parts
7 * @since 1.0.0
8 *
9 */
10
11
12$the_query = codeless_get_related_posts( get_the_ID(), 4 );
13global $cl_from_element;
14$cl_from_element['is_related'] = true;						
15// Display posts
16if ( $the_query->have_posts() ) : 
17
18?>
19<div class="cl-entry-single-section cl-entry-single-section--related">
20  <h6 class="cl-entry-single-section__title cl-custom-font"><?php echo esc_attr__( 'Related Posts', 'thype' ) ?></h6>
21  <div class="cl-blog cl-blog--style-simple-no_content cl-blog--module-carousel">
22    <div class="cl-blog__list cl-items-container cl-carousel owl-carousel owl-theme" data-dots="1" data-nav="0" data-items="2" data-responsive='{"0": {"items":1}, "992": { "items":2 } }'>
23      <?php $i = 0;
24        while ( $the_query->have_posts() ) : $the_query->the_post();
25        
26
27        if( has_post_thumbnail() ){
28          get_template_part( 'template-parts/blog/style-simple-no_content' );
29          $i++;
30        }
31          
32        if( $i == 2 )
33          break;
34
35        endwhile;
36      ?>
37    </div>
38  </div>
39</div>
40
41<?php endif; 
42
43wp_reset_query();
44$cl_from_element['is_related'] = false;
45?>
46