5 Custom field data wordpress plugin
5.Custom field data
==========================================================================================================
/*
*
*nwpt testimonial loop
*
*
*/
function nwpt_testimonial_loop(){ ?>
<div id="testimonial-slider" class="owl-carousel">
<?php
// WP_Query arguments
$args = array(
'post_type' => array( 'testimonial' ),
'post_status' => array( 'publish' ),
);
// The Query
$nwpt_query = new WP_Query( $args );
// The Loop
if ( $nwpt_query->have_posts() ) {
while ( $nwpt_query->have_posts() ) {
$nwpt_query->the_post();
// do something
?>
<div class="testimonial">
<div class="pic">
<img src="<?php echo get_the_post_thumbnail_url(get_the_ID(),'full'); ?>" alt="<?php the_title(); ?>">
</div>
<h3 class="title"><?php the_title(); ?></h3>
<p class="description"><?php the_excerpt(); ?></p>
<div class="testimonial-content">
<div class="testimonial-profile">
<h3 class="name"><?php echo get_post_meta( get_the_ID(), 'testi_name', true ); ?></h3>
<span class="post"><?php echo get_post_meta( get_the_ID(), 'testi_designation', true ); ?></span>
</div>
<ul class="rating">
<?php
$nwpt_client_review = get_post_meta( get_the_ID(), 'testi_rating', true );
if($nwpt_client_review =='1'){
echo "<li class='fa fa-star'></li>";
}elseif($nwpt_client_review =='2'){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li>";
}elseif($nwpt_client_review =='3'){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li>";
}elseif($nwpt_client_review =='4'){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li>";
}elseif($nwpt_client_review =='5'){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li>";
}elseif($nwpt_client_review =='4.5'){
echo "<li class='fa fa-star'></li>
<li class='fa fa-star'></li>
<li class='fa fa-star'></li>
<li class='fa fa-star'></li>
<i class='fa fa-star-half' aria-hidden='true'></i>";
}else{
echo "Rating not found";
}
?>
</ul>
</div>
</div>
<?php }
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
</div>
<?php }
....................................
No comments