Tag Archive for: WordPress

Pages

pages

WordPress had a point release update earlier this week, 4.4.1. And it broke my website.

The pagination at the bottom of the site would not work. It would only return to the front page of the site.

I use the Enfold theme for this website so I thought I should check there first. And, sure enough, lots of sites were reporting the same problem.

I logged a support request and I was asked to try a lot of code changes. No joy. Nothing worked.

Finally, it became evident that the root cause was not in the theme itself but somewhere in the core of the most recent release of WordPress. You can find the rather curious thread about that particular bug here. It makes for some fascinating reading about how open source issues are identified, tracked and resolved.

Funny how little things have changed. We still have to write code not unlike how we did several decades ago.

I was looking at some old C code that I had written back in the early 1990s — over 25 years ago. I had written a text editor and here is one of the functions from my source code:

EditFileC

And here is the PHP code that I had to change in the WordPress core to regain the pagination function for the blog. I needed to remove the section of code with the comment “Old Post Paging” and replace it with the new section of code “New Post Paging”:

FixPaginationPHP

That PHP code does not look very elegant to me. Whenever I see multiple AND operators in a conditional statement with further nested conditional statements I get a bit nervous. It looks like a quick patch. It works but it doesn’t look very refined.

WordPress is largely built on PHP and PHP is very similar in syntax to C. The PHP code, though, just looks a bit “thick” to my eye.

C is still an incredibly elegant and poetic programming language. I always enjoyed producing compact, efficient software in C.

Dennis Ritchie was a genius.

Housekeeping

Upgraded the blog to WordPress 2.7 and made a few little tweaks to the style sheet.

WordPress 2.5

I upgraded the blog to WordPress 2 dot 5. Carry on.

Code is Poetry

And it can also be frustrating. I have been coding up a website for a friend and I was testing the blog component for scale. I have allowed for a user-defined maximum of posts visible on a page. I have code that allows a user to scroll through prior posts.

I started the test case thinking that it would take just a few minutes. I added about 40 posts to ensure that the scrolling would work. However, I kept getting the same ten posts over and over. The previous and next links would show as expected but the posts would not change.

I spent almost ten hours debugging this particular function. The solution, buried deeply in one of the WordPress forums, was obvious:

<?php {$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;  query_posts(“cat=1&paged=$paged”); } ?>

Code is poetry. It works now. I can take some time off to celebrate my birthday.

Technology Pains

Red Ring of Death

The first pain is the infamous Red Ring of Death. My youngest son was in tears when I told him that his xbox 360 had failed.

“Can’t you just fix it Dad?”

I googled the Red Ring of Death and showed him several of the results. He insisted on following all of the troubleshooting steps from this site before he would accept that his machine was simply not going to work.

I have no idea whether Microsoft will repair the box. We’ll call support and find out. Although it could be viewed as a positive development, fewer hours in front of a video screen, I know he really does enjoy gaming on the xbox.

Uncategorized

Almost all of the posts on this blog are now uncategorized.

I have been working on a new design for the blog. It will be quite a departure from the last few styles. And I have built this one from the ground up. Everything from the design to the code. I took inspiration from Smashing Magazine. That site has some great resources for web developers and designers.

The design looks great and should be up and running in a few more weeks.

I have been coding the site on my local machine running the latest revision of WordPress. And, to get my site ready for the new design, I decided to upgrade the blog to the latest version of WordPress as well.

A new feature in this release is tagging. As part of the update, I was able to convert all of my categories to tags.

Big mistake. I lost all of the categories assigned to posts except for the category called general. I have 1,252 posts that no longer have categories. And many of the categories are quite popular with readers. For example, I have a set of posts with pictures of high-end recording studios. They were easily accessible via the category of Recording Studios.

Gone for the time being. Over the next month or so, I will repopulate the category fields. Likely as I am watching the CBC news. I have to do this manually, one post at a time.

Cellphone Contracts

There is no more difficult task in the modern age than canceling a cellphone contract. I had three cellphones under contract with Telus and one of them expired the end of January.

We only need two cellphones. The task seemed simple enough: do not renew the expired phone. The only twist is that we needed to switch the number from the canceled handset to another.

How many hours did this take? 5? 10? 15? I’ve lost count of the number of telephone calls to make this simple change happen. However, the icing on the cake was when I finally got Telus to cancel the contract. There. Finally. Everything all set.

My wife called a couple of days later to confirm and Telus had no record that I canceled. I had to call them. Again.

So I did.

“I understand that I need to call and confirm the contract that I had canceled previously should be canceled.”

“Yes, Mr. Cleaver. That is correct. Can I ask why you are not renewing the contract?”

Lots of blah, blah as we replayed the dozens of hours of prior discussions, switching of agents, etc.

“Mr. Cleaver, everything is all set. Your contract will be canceled next month.”

“Next month?”

“Yes. We require 30 days notice.”

We started the process six weeks back.

Sigh.

Anatomy of a Web Design

As mentioned in an earlier post, I am helping a friend to build and deploy his new website.

We decided to use WordPress, a content management system, as the platform for updating information on the site. The look and feel of the site will be independent of the content.

We moved his site to myhosting.com, an excellent hosting company based in Toronto. I put up an under construction page and I also installed and tested the latest version of WordPress. Everything works as expected.

The next steps will be to build out the information hierarchy for the site and enter the content. After that, we will apply the new design elements and open the site.

My friend is a very talented musician and he is also active in ministry and teaching. In terms of presenting on the web, I suggested that he review 15 or 20 similar websites and make notes on what he likes and does not like about their designs. I also suggested that he think about his target audience and what they would need from his site.

I gave him links to a few sites of the top Christian artists in Canada and the United States. Some very interesting designs although I must admit that they range from the horrible to the acceptable. Take a look and draw your own conclusions. In particular, think about the message that their sites present. From selling cruise vacations to shirts and hats, it is often difficult to find out whether they have a ministry or just a business.

Michael W. Smith
Chris Rice
Steve Bell
Chris Tomlin
Steven Curtis Chapman
Mercy Me
Jars of Clay

Apache, MySQL, PHP and WordPress

I’ll be doing some work with WordPress on another musician’s website. WordPress is an open source content management system. The blog you are reading is powered by WordPress.

Typically, a WordPress blog is driven by a LAMP server: Linux, Apache, MySQL and PHP. Because I run a Mac, I can host a WordPress environment on my local machine. I can use a Mac as if it were a LAMP server.

Apache is enabled by simply turning on Web Sharing under the Sharing option of System Preferences. Or, if you are a diehard Unix geek, you can bring up the Terminal app and enter:

sudo apachectl start

Make sure you have your root password handy.

PHP is installed in Mac OS X by default, but not enabled. To enable it, the Apache 2 configuration file, which is located at /etc/apache2/httpd.conf, has to be edited. There is a line which loads the PHP 5 module, which looks like this:

#LoadModule php5_module libexec/apache2/libphp5.so

Remove the comment symbol, #, and save the file. And restart Apache.

sudo apachectl restart

I had to download MySQL and install it myself. Not the most user friendly database install. And, even though I had the database up and running, my local install of WordPress would not connect to the database. It turns out that I had to edit a line in the wp-config.php file to replace localhost with a default IP address:

define(‘DB_HOST’,’127.0.0.1′);

After a few hours of Unix hacking, I had a full WordPress development machine on my Mac. Just like using a LAMP server on my ISP. For whatever reason, it felt good to still be able to hack around Unix, Apache, MySQL, PHP and WordPress.

I am a hopeless geek.