2012-04-04 123 views
0

我有這樣改變顏色的sprintf

$output.='<li class="'.$rcclass.'">' . 
/* translators: comments widget: 1: comment author, 2: post link */ 
sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . 
'</li>'; 

代碼我想%1 $ S有不同的顏色%2 $ S。 我怎麼在這裏做到這一點。 謝謝

回答

2

將它們包裝在<span>中,並且具有特定的類別,例如,

<span class='comment-author'>%1$s</span> on <span class='post-link'>%2$s</span> 

然後調整你的CSS來爲這些類顯示不同的顏色。

+0

試過。那沒有工作:( – Autolycus 2012-04-04 06:48:03

+0

奇嘗試此sprintf(_x('%2 $ s(%1 $ s)'', 'widgets')顏色不會改變,但字體會做!! – Autolycus 2012-04-04 06:57:29

+0

然後,無論在佔位符中插入的顏色設置是否覆蓋您的選擇,請嘗試使用'!important'以您自己的風格。 – Joey 2012-04-04 07:04:46