SEO Tip: Highlight Nofollow Links for Authors in WordPress
Hyperlinking is a tradition in blogging, but in Search Engine Optimization, every external link is a dangerous trap. As google says too many links are bad for you, on the other hand, too few is boring. So while linking to external sites you need to be careful, as it can affect your page ranking and also credibility of your site.
Here i will show you a simple CSS trick you should consider using for identifying nofollow links on your wordpress blog.
Step 1 Adding body class
This trick uses classes registered with body_class() function introduced in wp2.8. First we need to edit header.php
so it will add appropriate body classes when rendered:
[note]Please note that, most of themes have that tag already added to body now. You’d better check your pages html code (Right click → View Source) for <body class=" ... logged-in .. " >
. If logged-in
exists you can skip this step.[/note]
1. Open header.php
in your theme folder.
2. Find <body>
tag in the file and insert the following function inside:
<body <?php body_class(); ?>>
3. Save & upload it if necessary.
This will ensure your body has necessary CSS class to style nofollow links. When an author is logged in this function adds logged-in css class in your body tag so you can change styles for logged in users.
Step 2 Adding style
Let’s apply nofollow highlight using this class:
1. Open style.css
in your theme folder.
2. Add the following line:
.logged-in a[rel~="nofollow"] { border: 1px dotted #F60; }
3. Save the file & upload.
Now when you visit your site, you will see nofollow links with a border around them.