2013-01-09 59 views
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>兩次。

+0

更好地發佈實際產生的HTML比僞代碼。 – Popnoodles

回答

1
您的循環中

要追加

$fav_post .= 

則呼應

echo $fav_post; 

決不內環路設置爲空白。刪除期間或只是回顯線

echo $entry_before."<a href='"... 
+0

輝煌,謝謝。 – Talha