Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) );
- if( $related ) foreach( $related as $post ) {
- setup_postdata($post); ?>
- <ul>
- <li>
- <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
- <?php the_content('Read the rest of this entry »'); ?>
- </li>
- </ul>
- <?php }
- -------=--=-=-=-
- <?php
- $related = new WP_Query(
- array(
- 'category__in' => wp_get_post_categories( $post->ID ),
- 'posts_per_page' => 2,
- 'post__not_in' => array( $post->ID )
- )
- );
- $user = wp_get_current_user();
- if( $related->have_posts() ) {
- while ($related->have_posts()) : $related->the_post(); ?>
- <div class="col-xl-6 col-md-6 col-12">
- <div class="single-blog-item">
- <div class="featured-thumb">
- <img src="<?php the_post_thumbnail(); ?>" alt="<?php the_title(); ?>">
- </div>
- <?php if( '1' == $is_post_date): ?>
- <span class="post-date"><?php the_time(get_option('date_format')) ?></span>
- <?php endif; ?>
- <div class="post-meta">
- <div class="post-athuor">
- <?php if ($user) : ?>
- <div class="author-img" style=" background-image: url(<?php echo esc_url(get_avatar_url($user->ID)); ?>)"></div>
- <?php endif; ?>
- <a href="<?php echo get_author_posts_url(get_the_author_meta('ID'), get_the_author_meta('user_nicename')); ?>"><?php the_author(); ?></a>
- </div>
- <div class="post-comment">
- <a href="<?php the_permalink() ?>"><i class="far fa-comment-dots"></i><?php echo get_comments_number(); ?> Comments</a>
- </div>
- </div>
- <div class="post-content">
- <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
- <p><?php echo strip_shortcodes(saasnext_excerpt('saasnext_opt', 'blog_excerpt', true)); ?></p>
- <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" class="read-btn">Read More <i class="far fa-long-arrow-alt-right"></i></a>
- </div>
- </div>
- </div>
- <?php
- endwhile;
- wp_reset_postdata();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement