0

我正在尝试修改的 wordpress 插件中有一个循环。

$dataarray = explode(',',$data);
foreach ($dataarray as $entry){
    $sql .= "OR ID = '$entry' ";
}   

$endvar = wp_parse_args( $var, $defaults );
extract( $endvar, EXTR_SKIP );
$sql = preg_replace("/^OR./","", $sql); 
$order = $endvar['order_by'];
$my_posts = $wpdb->get_results("SELECT * FROM $table_name2 WHERE $sql ORDER BY $order");
$mod_url = mfp_create_link_url();

foreach ($my_posts as $entry){
    echo get_the_post_thumbnail($entry->ID, 'thumbnail');
    $fav_post .= $entry_before."<a href='".get_permalink($entry->ID)."' title='".$entry->post_title."' class='".$endvar['link_class']."'>".$entry->post_title."</a>".$entry_after;
    echo $fav_post;
    echo pippin_excerpt_by_id($entry);
}

这显示;

<thumbnail-1>
   <title-1>
     <excerpt-1>
<thumbnail-2>
   **<title-1>**
   <title-2>
     <excerpt-2>

我不明白为什么它显示<title-1>两次,而其他只显示一次。

4

1 回答 1

1

在您要附加的循环中

$fav_post .= 

然后回响

echo $fav_post;

切勿在循环内将其设置为空白。删除句号或只是回显该行

echo $entry_before."<a href='"...
于 2013-01-09T13:26:37.450 回答