Quantcast
Viewing all articles
Browse latest Browse all 10

Removing the Self Links on the Home Page

On a web site, there is no need to have a link to the home page on the home page itself! (It makes no sense for a web page to link to itself). This is a commonly known usability guideline, yet nearly all WordPress blogs and web sites have links on the home page to the home page.

In a new blog I am creating, I fixed this by modifying the header.php file in the theme. I did similar fixes to this blog as well.

Original code:

<div id=”h1″><h1>
<a href=”<?php bloginfo(‘url’); ?>” title=”<?php bloginfo(‘name’); ?>”><?php bloginfo(‘name’); ?></a>
</h1></div>

Modified Code:

<div id=”h1″><h1>
<?php
if (!is_home()) { ?>
<a href=”<?php bloginfo(‘url’); ?>” title=”<?php bloginfo(‘name’); ?>”><?php bloginfo(‘name’); ?></a>
<?php }
else {
echo bloginfo(‘name’);
}
?>
</h1></div>

Similarly, on the home page, “Home” should not be listed with the list of pages.

Original code:

div id=”tabs1″>
<ul>
<li><a href=”<?php bloginfo(‘url’); ?>” title=”Home”>Home</a></li>
<?php wp_list_pages(‘depth=1&title_li=’); ?>
</ul>
</div>

Modified Code:

<div id=”tabs1″>
<ul>
<?php if (!is_home()) { ?>
<li><a href=”<?php bloginfo(‘url’); ?>” title=”Home”>Home</a></li>
<?php } ?>
<?php wp_list_pages(‘depth=1&title_li=’); ?>
</ul>
</div>


Viewing all articles
Browse latest Browse all 10

Trending Articles