File: /mnt/data/dreamsrent-wp/wp-content/themes/dreamsrent/templates/blog-grid.php
<?php
/**
* Template Name: Blog Grid Template
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package WPVoyager
*/
get_header();
?>
<?php if( is_active_sidebar( 'blog-sidebar' )) {
$blog_type ="col-lg-8";
} else {
$blog_type ="col-lg-12";
}
?>
<section class="blog-section">
<div class="container">
<div class="row">
<div class="<?php echo esc_attr($blog_type); ?>">
<div class="row">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = get_option( 'posts_per_page' );
$args=array(
'post_type' => 'post',
'paged' => $paged,
'posts_per_page' => $post_per_page,
'parent' => '',
'orderby' => 'id',
'order' => 'ASC'
);
$wp_query = new WP_Query($args);
if( have_posts() ) :
while ($wp_query->have_posts()) : $wp_query->the_post();
$post_date = get_the_date();
?>
<div class="col-lg-6 col-md-6 d-lg-flex">
<div class="blog grid-blog">
<?php if(has_post_thumbnail()){ ?>
<div class="blog-image">
<a href="<?php the_permalink(); ?>">
<?php
dreamsrent_content_thumbnail('dreamsrent_m'); ?>
</a>
</div>
<?php } ?>
<div class="blog-content">
<p class="blog-category">
<?php
$categories_list = wp_get_post_categories($wp_query->post->ID);
$cats = array();
$output = '1';
foreach($categories_list as $c){
$cat = get_category( $c );
$cats[] = array( 'name' => $cat->name, 'slug' => $cat->slug, 'url' => get_category_link($cat->cat_ID) ); ?>
<a href="<?php echo esc_url(get_term_link($cat->slug, 'category')) ?>"><span> <?php $single_cat_display= $cat->name; echo esc_html($single_cat_display,'dreamsrent'); ?> </span></a>
<?php
if( $output=='2') {
break;
}
$output++;
} ?>
</p>
<h3 class="blog-title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h3>
<p class="blog-description"><?php echo wp_trim_words( get_the_content(), 30, ' ...' );?></p>
<ul class="meta-item">
<li>
<div class="post-author">
<div class="post-author-img">
<?php echo get_avatar( get_the_author_meta('ID'), 30); ?>
</div>
<a href="javascript:void(0)"> <span> <?php the_author(); ?> </span></a>
</div>
</li>
<li class="date-icon"><i class="fa-solid fa-calendar-days"></i> <span><?php echo esc_html($post_date);?></span></li>
</ul>
<a href="<?php the_permalink(); ?>" class="viewlink btn btn-primary"><?php echo esc_html__('Read More','dreamsrent'); ?> <i class="feather-arrow-right ms-2"></i></a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php
dreamsrent_pagination_theme();
wp_reset_query();
?>
<?php endif; ?>
</div>
</div>
<?php if( is_active_sidebar( 'blog-sidebar' )) { ?>
<div class="col-lg-4 theiaStickySidebar">
<div class="rightsidebar">
<?php get_sidebar();?>
</div>
</div>
<?php } ?>
</div> <!-- row -->
</div>
</section>
<?php get_footer(); ?>