查看函数的声明the_title()
, 如果第三个参数$echo
设置为TRUE
默认设置为:
/**
* Display or retrieve the current post title with optional content.
*
* @since 0.71
*
* @param string $before Optional. Content to prepend to the title.
* @param string $after Optional. Content to append to the title.
* @param bool $echo Optional, default to true.Whether to display or return.
* @return null|string Null on no title. String if $echo parameter is false.
*/
function the_title($before = \'\', $after = \'\', $echo = true) {
$title = get_the_title();
if ( strlen($title) == 0 )
return;
$title = $before . $title . $after;
if ( $echo )
echo $title;
else
return $title;
}
所以要么你用
the_title( \'\', \'\', FALSE )
甚至更好
get_the_title()
因为它使代码更具可读性:
$title = get_the_title();
$args = array(
\'post_type\' => \'Testimonials\',
\'order\' => \'ASC\',
\'category_name\' => $title
);