我在functions.php 中使用循环,我知道循环不起作用。我必须全球化任何东西吗?我环顾四周,我不确定。这是我的功能:
function loadDiffSection($name)
{
$term = get_term_by('name', $name, 'category');
$termIdFeat = $term->term_id;
$everything = "";
if(have_posts() ):
query_posts("cat=".$termIdFeat."&posts_per_page=5");
$count = 1;
while(have_posts() ) : the_post();
set_post_thumbnail_size(520 , 0, true);
$everything .="<a href='?p=".the_ID()."'>";
$everything .="<div class='pushLeft grid thisPost pos_".$count."'>";
$everything .="<div class='capMedia hide'>";
$everything .="<font size='3'>".get_the_title()."</font><br /><br />";
$actualLen = strlen(strip_tags(removeImagefromContent()));
$limit = 200;
if($actualLen > $limit)
{
$everything .= substr(strip_tags(removeImagefromContent()), 0, $limit)."...";
}
else
{
$everything .= strip_tags(removeImagefromContent());
}
$everything .= "</div>";
$everything .= get_the_post_thumbnail();
$everything .= "</div></a>";
$count++;
endwhile;
endif;
header( 'Content-Type: application/json; charset=UTF-8' );
echo json_encode(array("returned" => $everything));
exit;
}
我正在使用此代码调用 AJAX 请求,因此它返回 NULL 响应。这让我相信循环在函数中不起作用。