任何人都可以解释为什么这只返回第一个结果。我想返回所有与当前网址具有相同自定义字段值的结果。它会返回1.它是否需要一个或每件东西?谢谢!!WordPress的短代码功能
<?php add_shortcode('feed', 'display_custom_post_type');
function display_custom_post_type(){
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$args = array(
'post_type' => 'custom_post_type',
'posts_per_page' => -1
);
$new_query = new WP_Query($args);
while($new_query->have_posts()) : $new_query->the_post();
return get_title();
endwhile;
};?>
为了简单起见,我已经从示例中删除了元查询。包含或不包含元查询的同样的问题也是有说服力的。谢谢! – dmt