// /----------------------- Custom Post type Testimonial ------------------------------------/
//Testimonial Post Type
add_action('init', 'tesimonial_post_type_init');
function tesimonial_post_type_init()
{
$labels = array(
'name' => __('Testimonial', 'post type general name', ''),
'singular_name' => __('Testimonial', 'post type singular name', ''),
'add_new' => __('Add New', 'Testimonial', ''),
'add_new_item' => __('Add New Testimonial', ''),
'edit_item' => __('Edit Testimonial', ''),
'new_item' => __('New Testimonial', ''),
'view_item' => __('View Testimonial', ''),
'search_items' => __('Search Testimonial', ''),
'not_found' => __('No Testimonial found', ''),
'not_found_in_trash' => __('No Services found in Trash', ''),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'rewrite' => true,
'query_var' => true,
'menu_icon' => "dashicons-testimonial",
'capability_type' => 'post',
'hierarchical' => true,
'public' => true,
'has_archive' => true,
'show_in_nav_menus' => true,
'menu_position' => null,
'rewrite' => array(
'slug' => 'testimonial',
'with_front' => true
),
'supports' => array(
'title',
'editor',
'thumbnail',
'excerpt'
)
);
register_post_type('testimonial', $args);
}
// Add Shortcode [our_testimonial];
add_shortcode('our_testimonial', 'codex_our_testimonial');
function codex_our_testimonial()
{
ob_start();
wp_reset_postdata();
?>
<div class="testimonialsSlider">
<?php
$arg = array(
'post_type' => 'testimonial',
'posts_per_page' => -1,
);
$po = new WP_Query($arg);
if ($po->have_posts()) :
while ($po->have_posts()) : $po->the_post(); ?>
<div class="testimonials_wrapper">
<div class="testimonials_content">
<div class="testimonial-content">
<div class="testipara"><?php echo wp_trim_words(get_the_content(), 50, '...'); ?></div>
</div>
<div class="footer-testimoni">
<div class="thumbnail-blog">
<div class="testimain">
<h3 class="testi-title"><?php the_title(); ?></h3>
<div class="short-desc"><?php the_excerpt(); ?></div>
<div>
<?php echo get_the_post_thumbnail(get_the_ID(), 'full'); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endwhile;
endif;
wp_reset_postdata();
?>
</div>
<?php
wp_reset_postdata();
return '' . ob_get_clean();
}