File: /var/www/html/pmw24/wp-content/themes/PunjabMotor/template-page/gallery_temp.php
<?php
/*
Template Name: Service Template
*
* Displays all of the head element and everything up until the "site-content" div.
*
* @package WordPress
* @subpackage Punjab_Motor
* @since Punjab Motor 1.0
*/ ?>
<?php get_header();?>
<!--header part end-->
<!--main body part start-->
<section id="inner_body">
<div class="container">
<div class="inner-page-contnt">
<div class="gallery-section">
<div align="center">
<?php $custom_terms = get_terms( 'project_category', array( 'hide_empty' => false, 'parent' => 0 ) ); ?>
<button class="btn btn-default filter-button" data-filter="all">All</button>
<?php foreach($custom_terms as $custom_term) { ?>
<button class="btn btn-default filter-button" data-filter="<?php echo $custom_term->slug; ?>"><?php echo $custom_term->name; ?></button>
<?php } ?>
</div>
<div>
<?php foreach($custom_terms as $custom_term) {
wp_reset_query(); ?>
<div class="gallerylist">
<?php $args = array('post_type' => 'our-project','posts_per_page' => -1, 'order' => 'DESC','orderby' => 'rand','tax_query' => array(array('taxonomy' => 'project_category','field' => 'slug','terms' => $custom_term->slug)));
$loop = new WP_Query($args); ?>
<?php if($loop->have_posts()) { ?>
<?php while($loop->have_posts()) : $loop->the_post(); ?>
<div class="col-md-3 col-sm-6 filter <?php echo $custom_term->slug; ?>">
<div class="gallery">
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>">
<img src="<?php echo esc_url( get_template_directory_uri() ); ?>/admin/timthumb/timthumb.php?src=<?php the_post_thumbnail_url('full'); ?>&a=c&q=100&w=344&h=252" alt=" ">
</a>
<?php } else { ?>
<a href="<?php the_permalink(); ?>"><img src="<?php echo esc_url( get_template_directory_uri() ); ?>/admin/timthumb/timthumb.php?src=<?php echo esc_url( get_template_directory_uri() ); ?>/assets/images/noimage.jpg&a=c&q=100&w=344&h=252" alt=" " /></a>
<?php } ?>
<h3><a href="<?php the_permalink(); ?>"><?php $title = get_the_title(); echo substr($title, 0, 20); ?></a></h3>
</div>
</div>
<?php endwhile; ?>
<?php } } ?>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</section><!--/#contact-page-->
<!--main body part end-->
<!-- footer Start-->
<?php get_footer();?>