php - Wordpress 如何将自定义类添加到作者名称以进行样式设置
问题描述
我在下面有这段代码可以在帖子标题下显示作者姓名,但是我如何为它分配一个类,以便我可以使用 css 更改它的样式,比如它的颜色和字体大小等?
<?php the_author_posts_link(); ?>
解决方案
the_author_posts_link 实际上回显了这种形式的锚标记
<a href="https://somewebsite.com/author/john-smith/" title="Posts by john.smith" rel="author">John.Smith</a>
最简单的格式化方法可能是将它包装在一个 div 中,它有一个独特的类,您可以在 Wordpress 后端的 Appearance>Cusomize 中设置它的样式
<div class="myAuthorStyle"><?php the_author_posts_link(); ?></div>
一个简单的样式示例:
.myAuthorStyle a {
color: magenta;
text-decoration: none;
font-size: 2em;
display: inline-block;
}
<div class="myAuthorStyle"><a href="https://somewebsite.com/author/john-smith/" title="Posts by john.smith" rel="author">John.Smith</a></div>
推荐阅读
- javascript - Angular:有一种方法可以与指令中的二级子组件交互吗?
- hadoop - 在长期运行的纱线应用程序中重新生成委托令牌
- c++ - 替换字符串中的单词,但忽略引号中的单词
- flutter - Flutter:当应用程序处于后台时无法显示本地通知
- javascript - Selenium python返回页面Head而不是Body
- javascript - 视频完成后播放下一组视频,例如应用状态
- r - 根据数据框中某一列的条件,删除同一行其他列中的数据
- typescript - 在 Typesript 中创建 FixedUpdate
- java - 如何在 Java Spark 中读取 avro 文件作为对象列表
- html - 如何使用 watir 和 children / xpath 来单击按钮?