Posted:July 15, 2005

Preparing to Blog – Permalink Problems

Two things broke in adding the WordPress permalink feature. This post describes those problems, attempted fixes and descriptions for each, then followed by current resolution and approach.

Why Permalinks?

Rather than use the ?page_id=num and ?p=num internal references for postings, WordPress provides a permalink feature that converts these ID references into URL strings that help in search engine indexing. Here is the permalink structure I settled upon for my site:

 /index/ai3v2/%year%/%postname%/

This produces a URL that contains a truncation of the post name title, plus other relevant information. That is well and good and the search engines would love me, but turning this feature on caused:  1) images were lost due to reference changes; and 2) Jonathan Foucher’s ‘Popular Posts’ plugin ceased displaying.

Lost Images

The first problem is that all of my site images no longer could be found. According to the last entries in the WordPress support file, I needed to add these lines of code to my main site index file:

  <?php $basehref = "http://".$_SERVER['SERVER_NAME'].($_SERVER['SCRIPT_NAME']); ?>

    <base href="<?php echo"$basehref"; ?>">

As well, I needed to preface my internal image references by ‘/index.php/’. 

These changes again allowed my images to be properly displayed, but I guess I’m not sure why all of the pieces worked. With this first problem fixed, I could now address the second.

Popular Links

I use Jonathan Foucher’s ‘most popular’ plugin, which broke when I introduced a permalink without an ID field. This plugin itself relies on the Randy Peterson’s StatTraq statistical reporting plugin.

In researching this problem, I came across a posting by Jonathan noting the issue was indeed when no post id is included in the permalink structure. Because the post id is not added to the StatTraq table in the ‘article_id’ field, it causes the ‘page views’ StatTraq report to show only ‘Mixed’ page views, not the actual posts viewed by visitors. I tried his suggested resolution by making these line (25 and 26) changes in the stattraq.php file:

if (($p != '')){
$p = intval($p);

With this replacement:

 if (($post->ID != '')){
$p = intval($post->ID);

Unfortunately, that did not fix my problem.

Resolution

Since I could not get images and popular links to work simultaneously, I decided to pass. I suspect that late updates to StatTraq and WordPress will better address these problems (Randy has announced a pending update for StatTraq). While I like the fact these tools are extensible and many discuss successful hacks, it does concern me to hack code unnecessarily that might make installing later upgrades and bug fixes even more problematic.

So, in thnking about the fact that AI3 is likely to be very content-filled anyway, I decided to put off resolving the permalink issue until another day. I’d already spent too many hours on a dead-end.

 

Author’s Note:  I actually decided to commit to a blog on April 27, 2005, and began recording soon thereafter my steps in doing so.  Because of work demands and other delays, the actual site was not released until July 18, 2005.  To give my ‘Prepare to Blog …’ postings a more contemporaneous feel, I arbitrarily changed posting dates on this series one month forward, which means some aspects of the actual blog were better developed than some of these earlier posts indicate.  However, the sequence and the content remain unchanged.  A re-factored complete guide will be posted at the conclusion of the ‘Prepare to Blog …’ series, targeted for release about August 18, 2005.  mkb

Schema.org Markup

headline:
Preparing to Blog – Permalink Problems

alternativeHeadline:

author:

image:

description:
Two things broke in adding the WordPress permalink feature. This post describes those problems, attempted fixes and descriptions for each, then followed by current resolution and approach. Why Permalinks? Rather than use the ?page_id=num and ?p=num internal references for postings, WordPress provides a permalink feature that converts these ID references into URL strings that help […]

articleBody:
see above

datePublished:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>