2012-04-04 121 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