Home How do I style a WordPress PHP link?
Reply: 1

How do I style a WordPress PHP link?

ebkod
1#
ebkod Published in 2017-12-07 21:45:17Z
<div class="past-page"><?php previous_posts_link( '&laquo; Previous Page' ); ?></div>

Hello! I'm having a bit of troubles trying to solve the styling of a pagination button. I tried styling the past-page div, but that made a white box show up when no link was there... which was not the result I wanted.

So, I'm wondering if I can somehow add styling in the php tag here? The style I want to add is

font-size: 10pt;
text-transform: uppercase;
font-weight: bold;
background: #fff;
padding: 10px;
Nerds of Technology
2#
Nerds of Technology Reply to 2017-12-07 22:10:46Z

use :not(:empty) to add style to a div that is 'not empty'; otherwise, when it is blank, it reverts back to the default CSS:

<style>
.past-page:not(:empty) {
 font-size: 10pt;
 text-transform: uppercase;
 font-weight: bold;
 background: #fff;
 padding: 10px;
}
</style>

Alternatively, you could apply the style always unless empty then make it invisible:

<style>
.past-page {
 font-size: 10pt;
 text-transform: uppercase;
 font-weight: bold;
 background: #fff;
 padding: 10px;
}

.past-page:empty {
 display: none !important;
}
</style>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.318103 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO