Php 将CSS类名添加到WordPress主题中的注释\弹出\链接。

Php 将CSS类名添加到WordPress主题中的注释\弹出\链接。,php,css,wordpress,Php,Css,Wordpress,我目前正在尝试设计一个Wordpress主题,我没有最棒的PHP知识,但到目前为止进展得相当不错 我的一个问题是,如何添加类和ID以将CSS挂接到其中?例如: 在每篇文章上生成“留下评论”链接的代码为: <?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?> ^猜测这根本不对。这样就可以了: <span class="commentLnk"><?php comments

我目前正在尝试设计一个Wordpress主题,我没有最棒的PHP知识,但到目前为止进展得相当不错

我的一个问题是,如何添加类和ID以将CSS挂接到其中?例如:

在每篇文章上生成“留下评论”链接的代码为:

<?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?>

^猜测这根本不对。

这样就可以了:

<span class="commentLnk"><?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?></span>

或者,该函数还接受第四个参数,该参数将用作类:

<?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments', 'commentLnk'); ?>

您可以将自己的CSS样式类添加到评论链接

评论\弹出\链接('留下评论','1评论','%comments','cssclass')


正如.p>的WordPress API文档中所解释的,您需要找到“comments\u popup\u link”函数,并允许它接受和使用您选择的参数。@Diodeus我会在哪里找到它,我需要使用什么来接受这些参数?有没有一种不使用CSS而更容易指定的方法?我不知道Wordpress的内部工作原理,但很可能它已经提供了有意义的类和ID。也许你可以在你的CSS中覆盖这些。看看网页的来源吧?@jordi12100不要否决投票,编辑@Diodeus不正确-您根本不需要修改函数。
<?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments', 'commentLnk'); ?>