gpt4 book ai didi

php - 将 CSS 类名称添加到 WordPress 主题中的 comments_popup_link。

转载 作者:太空宇宙 更新时间:2023-11-03 20:01:32 25 4
gpt4 key购买 nike

我目前正在尝试设计一个 Wordpress 主题,我没有最丰富的 PHP 知识,但到目前为止进展顺利。

我的一个问题是,如何添加类和 ID 来 Hook 我的 CSS?例如:

在每个帖子上生成“发表评论”链接的代码是:

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

我想设置它的样式,它显示为一个链接,但显然我不能简单地为我的主栏中的每个 a 标记更改 CSS。我需要添加某种类来 Hook 。

我该怎么做?

<?php class="commentLnk" 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'); ?>

关于php - 将 CSS 类名称添加到 WordPress 主题中的 comments_popup_link。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14369144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com