บ่อยครั้งที่เราต้องเรียกใช้งานฟังก์ชั่นที่เรา Custom มาเอง
add_shortcode('testimonials_loop', 'testimonials_query');
function testimonials_query($atts){
echo $atts['id'];
$args = array(
'post_type' => 'testimonials',
'orderby' => 'order',
'order' => 'ASC'
);
$query = new WP_Query($args);
if($query->have_posts()){
while($query->have_posts()) : $query->the_post();
$html = get_the_title().'<br>';
$html .= get_the_ID();endwhile;
}
return $html;
}//End function
ในการเรียกใช้งาน shortcode นี้ แบบ PHP เรียกได้จาก
<?php echo do_shortcode('[testimonial_rotator id=7296]'); ?>