2012-05-31 31 views
0

我正在編輯一個WordPress插件,爲相關博客文章提供建議。如何從此PHP代碼段中刪除類別?

這裏是它現在怎麼看起來截圖:

enter image description here

我希望它看起來完全一樣的屏幕截圖,但沒有「感恩,幸福」的鏈接...這只是鏈接到類別。保留「爲您推薦」和鏈接到文章,但刪除鏈接到類別。

如果我從下面的代碼中刪除了「foreach($ siblings as $ url => $ name)」代碼段,那麼它將刪除類別,但會混淆鏈接到推薦文章。

我該如何編輯它?要刪除類別但保留其他所有內容?

注意:我不確定這是否適用於下面的代碼,但插件會根據上一篇文章在相同類別中選擇推薦的文章。

 ob_start(); 
    do_action('iworks_upprev_box_before'); 
    $value .= ob_get_flush(); 
    if ($iworks_upprev_options->get_option('header_show')) { 
     $value .= '<h6>'; 
     if (count($siblings)) { 
      $value .= sprintf ('%s ', __('Recommended for You')); 
      $a = array(); 
      foreach ($siblings as $url => $name) { 
      $a[] = sprintf('<a href="%s" rel="%s">%s</a>', $url, $current_post_title, $name); 
      } 
      $value .= implode(', ', $a); 
     } else if ($compare == 'random') { 
      $value .= __('Read more:', 'upprev'); 
     } else { 
      $value .= __('Read previous post:', 'upprev'); 
     } 
     $value .= '</h6>'; 
    } 

回答

0

它看起來像所有你需要做的只是註釋掉該行或將其刪除:

$value .= implode(', ', $a); 

您也可以發表評論/刪除下面的代碼行:

$a = array(); 
foreach ($siblings as $url => $name) { 
    $a[] = sprintf('<a href="%s" rel="%s">%s</a>', $url, $current_post_title, $name); 
} 
+0

完美。謝謝你的幫助。並稱贊領主StackOverflow。 –

相關問題