4 Custom post loop wordpress plugin
4.Custom post loop
======================================================================================================
//query generate korte hobe generatewp.com theke
/*
*
*nwpt testimonial loop
*
*
*/
function nwpt_testimonial_loop(){ //function ta nije hate use korte hobe code editor e.
// 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
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
}
...................
/*
*
*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' ),
'post_per_page' =>10
);
// 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">
<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-half-empty"></li>
</ul>
</div>
</div>
<?php
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
</div>
<?php
}
..........................................
No comments