ClockInfo.com
Commentary about clock repair and clock history (with some tidbits on web site development)

ClockInfo.com

Modifying WP PageNavi Plugin

November 22, 2007 . by Bill

I wanted the navigation elements of WP-Pagenavi to be centered on the page, and the current page number to be above the previous - next navigation, and not have a box around it.

In pagenavi.php, change line 8 from:

echo ‘<span class=”pages”>’.$pages_text.’</span>’;

to:

echo ‘<p class=”pages”>’.$pages_text.’</p>’;

Add the following to pagenavi-css.css:

.wp-pagenavi {
text-align: center;
}

Change the following lines in pagenavi-css.css from:

.wp-pagenavi span.pages {
padding: 2px 4px 2px 4px;
margin: 2px 2px 2px 2px;
color: #000000;
border: 1px solid #000000;
background-color: #FFFFFF;
}

to:

.wp-pagenavi p.pages {
padding: 2px 4px 2px 4px;
margin: 2px 4px 6px 2px;
color: #000000;
background-color: #FFFFFF;
}

You can see it on this web page on the Flora First Christian Church website.


Removing the Self Links on the Home Page

November 3, 2007 . by Admin

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>


WordPress Permalink Format

July 6, 2007 . by Admin

Today I changed my WordPress permalink format to /posts/post_id

At first, I used the default date format /year/month/day/post_name but then decided that dates were not useful information in the URL.

Next I tried /category/post_name, but the URLs were just too long to look “pretty”. (And I thought that if I ever re-named a post, the URL would change. I learned that this is not necessarily the case, as the post_name in the URL is actually the “slug”, which does not change when the post name changes, but can be changed manually if desired).

Then I used /category/post_id, which seemed very good, until I realized that If I ever reorganize my categories, the permalinks will change, leading to bad links. As the blog grows, I can foresee the categories changing. For example, if one category gets many, many entries, it could make sense to divide it into sub-categories.

Finally (I hope its final!), I changed the permalink format to /posts/post_id, which I believe will actually result in permanent permalinks. The post_id will never change, even if the post’s date, name or category is changed. Having the word “posts” in the URL is a good idea, so there will be no confusion with the URL for your “pages” such as “About” which do not have any prefix in the URL (for example the URL for my “About” page is http://clockinfo.com/about, but a typical URL for a post is http://clockinfo.com/posts/18).

There is lots of debate over whether keywords in the URL help with search engine indexing. In my opinion, the content of a web page should matter to the search engine, not the URL, otherwise people could use all kinds of spam words in the URL to make a web page rank better. I will take my chance with short, simple permalinks and see what happens.

I hope now that I can leave my permalink format alone, so that the Google indexing will stabilize. If you think that I am making a big mistake (or agree with me), please comment!

(Note: don’t change your permalink format if your site has been active for a while unless you install a plugin to redirect old URLs to new URLs. This blog is just a few weeks old so I felt free to make changes.)


Setting up WordPress

June 14, 2007 . by Admin
  1. When trying to install the Independence Day theme, the following error message appeared: Warning: array_merge() [function array_merge]: Argument 2 is not an array in: …/wp-includes/widgets.php on line 53. Based on the comments on this post:
    http://www.gudlyf.com/2005/01/14/wordpress-plugin-technotag/feed/
    I changed line 53 of wp-includes/widgets.php to:
    $sidebar = array_merge($defaults, (array)$args);
    The change casts argument 2 to the array type, and seems to work fine.
  2. I have multiple links categories (Blogroll, Clock History Links, etc) and my pages would not pass XHTML validation, due to repeated use of an id by the widget code. The WordPress forum gave the following fix: Insert the following line of code as the first statement after the else { on line 360 of wp-includes/widgets.php:
    $before_widget = preg_replace('/id="[^"]*”/’,'id=”%id”‘, $before_widget);

The above applies to WordPress version 2.2.

A side note: Dreameaver MX was adding multiple attributes such as mmTranslatedValueHiliteColor=”HILITECOLOR=%22Dyn%20Untranslated%20Color%22″ to the page, so I used jEdit instead for editing, and used Dreamweaver only for site management such as uploading files. I can’t explain why Dreamweaver is messing things up, I have the preferences set for it not to do code rewriting.

Another problem I had (never solved) with Dreamweaver MX editing php files was that in some cases it was replacing a require_once statement withe contents of the included file! I hope to try the latest version of Dreamweaver later this year and see if it is fixed.


Next Entries »