Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prosantamazumder/050b69ae2c88954a61022d7cf3863303 to your computer and use it in GitHub Desktop.
Save prosantamazumder/050b69ae2c88954a61022d7cf3863303 to your computer and use it in GitHub Desktop.
<div class="blog-list-area">
<div class="container">
<?php
$custom_terms = get_terms(
'portfolio_cat',
array(
'orderby' => 'name',
'order' => 'DESC',
'hide_empty' => 1,
)
);
foreach( $custom_terms as $custom_term) :
wp_reset_query();
$args = array(
'post_type' => 'portfolios',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'portfolio_cat',
'field' => 'slug',
'terms' => $custom_term->slug,
),
),
);
?>
<div class="row border-row">
<div class="col-lg-3 col-md-4 col-sm-12 col-xs-12">
<div class="blog-left-side widget">
<div class="widget-sidebar-box">
<?php
$loop_cat = new WP_Query($args);
if($loop_cat->have_posts()) :
$link = get_term_link( $custom_term, 'portfolio_cat' );
$category_image = get_term_meta( $custom_term->term_id, 'category_image', true );
$cat_images = wp_get_attachment_image_src($category_image, 'full');
?>
<div class="popular-post-box">
<div class="popular-post-box-inner">
<?php if($cat_images) : ?>
<div class="popular-post-thumb">
<a href="<?php echo $link; ?>">
<img src="<?php echo $cat_images[0]; ?>" alt="" />
</a>
</div>
<?php endif; ?>
<div class="popular-post-content">
<a href="<?php echo $link; ?>"><?php echo $custom_term->name; ?></a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-9 col-md-8 col-sm-12 col-xs-12">
<div class="row">
<?php
while($loop_cat->have_posts()) : $loop_cat->the_post();
$trim_content = wp_trim_words( get_the_content(), 6, '...' );
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
?>
<div class="col-lg-3 col-md-4 col-sm-12">
<div class="single_blog style-three">
<div class="single_blog_thumb">
<a href="<?php the_permalink(); ?>">
<img src="<?php echo $image[0]; ?>" alt="" />
</a>
</div>
<div class="single_blog_content">
<div class="blog_page_title">
<h4><a href="<?php the_permalink(); ?>"><?php echo wp_trim_words( get_the_title(), 3, '..' ); ?></a></h4>
</div>
<div class="datatech_blog_meta">
<a href="<?php the_permalink(); ?>"><?php echo $trim_content; ?><span></span></a>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach;?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment