[英]How to add a css class to this php code
I am wondering how to add a css class to this part of the code which is linking to the older posts on a blog. 我想知道如何将CSS类添加到链接到博客上较早文章的代码的这一部分。
<?php posts_nav_link(' — ', __('« go back'), __('keep looking »')); ?>
Thanks! 谢谢!
You can do something like this:- 您可以执行以下操作:
<div class="YOUR-CLASS">
<?php posts_nav_link(' — ', __('« go back'), __('keep looking »')); ?>
</div>
See Documents Here . 请参阅此处的文档 。
Hope this will help you.. 希望这个能对您有所帮助..
There's a jQuery way for issues like this, when you're not able to add classes to WP functions. 当您无法向WP函数添加类时,有一种jQuery方式可解决此类问题。 Just add the class via jQuery: 只需通过jQuery添加类:
HTML HTML
<div class="navigation">
<?php posts_nav_link(' — ', __('« go back'), __('keep looking »')); ?>
</div>
jQuery jQuery的
$(function() {
$('.navigation a:first-child').addClass('your-class');
});
This will add a class to the first link in the div. 这会将一个类添加到div中的第一个链接。
There's a CSS way as well without adding a class but properties: 还有一种CSS方式,不添加类,而是添加属性:
.navigation a:first-child {
/* your properties here */
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.