TOPIC: AUTOMATTIC
Redirecting a WordPress site to its home page when its loop finds no posts
5th November 2022Since I created a bespoke theme for this site, I have been tweaking things as I go. The basis came from the WordPress Theme Developer Handbook, which gave me a simpler starting point shorn of all sorts of complexity that is encountered with other themes. Naturally, this means that there are little rough edges that need tidying over time.
One of these is dealing with errors on the site, like when content is not found. This could be a wrong address or a search query that finds no matching posts. When that happens, there is a redirection to the home page using some simple JavaScript within the loop fallback code enclosed within script start and end tags (including the whole code triggers the action from this post so it cannot be shown here):
location.href="[blog home page ]";
The bloginfo
function can be used with the url
keyword to find the home page, avoiding hard-coding. For now, this works so long as JavaScript is enabled, but a more robust approach may come in time. It is not possible to do a PHP redirect because of the nature of HTTP: when headers have been sent, it is not possible to do server redirects. At this stage, things become client side, so using JavaScript is one way to go instead.
Turning off the full height editor option in WordPress 4.0
10th September 2014Though I casually follow WordPress development, it's not nearly as rigorous as when I submitted a patch that earned me a mention on a main WordPress release's contributor list. This may explain why I barely noticed the full editor setting, which is turned on by default.
WordPress has become so mature now that I almost do not expect major revisions like the overhauls received by the administration back-end in 2008. The second interface was got so right that it still is with us, even if there were concerns in my mind at the time as to how usable it would be. Sometimes, those initial suspicions can come to nothing.
However, WordPress 4.0 introduced a major editor change that I'm not sure is successful. A full-height editor sounds good in principle, but its implementation has rough edges that make me wonder if any UX person reviewed it. Scrolling becomes strange, with the editor's toolbar fixing in place when you scroll down far enough. The sidebar then scrolls out of sync with the editor box, creating an odd sensation. Keyboard shortcuts like CTRL + HOME and CTRL + END don't work properly, which convinced me this new arrangement wasn't for me and I wanted to disable it.
A Google search found nothing useful, so I tried the WordPress.org forum. This revealed I should have looked in the screen options dropdown box for "Expand the editor to match the window height" to deselect it. Because of a Visual Editor control there, I'd checked the user profile screen but found nothing, showing the setup logic is poor. Perhaps the Visual Editor option should be a screen option too. Thankfully, the window height editor setting only needs changing once for both posts and pages, covering all situations.
With a distraction-free editing option available, I'm not sure why someone added the full height editor too. If WordPress keeps this feature, it needs refinement to behave more conventionally. I wouldn't build a website with such ill-synchronised scrolling. This needs work, as does the Visual Editor setting location. Perhaps both settings should be at the user level, rather than having one above that level. Before finding the solution, I considered using distraction-free mode permanently and installed the WP Editor plugin. I kept the plugin for its code highlighting, even though entering code view always creates a new revision. Despite this issue, things are now better.
Changing to CKEditor from FCKEditor for WordPress Content Editing
25th April 2011The post editor that I have been using on my WordPress-powered outdoors blog has not been TinyMCE but FCKEditor. My use of that editor has meant that WordPress' autosave and word counting features have not been available to me. As strange as it may sound to some, that is my choice. Even so, there have been times when I have missed the autosaving functionality and lost work.
Since FCKEditor has been replaced by CKEditor, there are plugins available for adding that editor to WordPress' administration interface. Recently, I replaced the old FCKEditor plugin with a newer CKEditor one, which has gained me post or page autosaving. Though the more cosmetic word counting feature is not active until a draft is manually saved, I can live with that.
Other than that, the interface remains familiar with all (X)HTML tags shown in the source code view without any being hidden away from view like on WordPress' implementation of TinyMCE. That isn't to see that WordPress is doing something wrong, only that there are alternative ways of doing things, that are equally valid. After all, why would there be choices if there only ever was one right way to do anything?
Like any WordPress plugins, those replacing the default content editor on WordPress can be vulnerable to changes in the publishing platform, and there is one of those in the pipeline for 3.2: a minimalist post/page editor that is billed as being non-distracting. That planned new feature is drawing inspiration from the likes of QuietWrite, where you can write content and transfer it over to WordPress or leave it where it was written.
Even with substantial changes like this, my experience never has been that design decisions made for new WordPress releases have restricted to any great extent how I use the thing. That's not to say that my usage hasn't changed over time, yet I have felt that any decisions were mine to make and not all made for me. In that light, I can foresee CKEditor continuing to work on WordPress 3.2 along with some testing ahead of time to be sure that is the case.
Turning off the admin bar in WordPress 3.1
25th October 2010Work on WordPress 3.1 is in full swing at the moment, though I initially thought that they were taking a little break after 3.0. From what I can see, many refinements are being made to the multi-blog functionality and behind-the-scenes work is ongoing on the administration screens too.
Another under-the-bonnet change has been to make WordPress less tied to MySQL, since the possibility of dropping in support for an alternative such as PostgreSQL is now a reality even if it isn't part of the default package. For now, it looks as if this will be plugin territory rather than default multi-database support, though that may become a sensible development in the light of Oracle's acquisition of MySQL and its sabre-rattling regarding Java patents. So far, the change to WordPress has affected my use of its database engine to power an offline version of my online photo gallery, but a quick spot of code editing sorted that issue.
One more obvious alteration will be the addition of a WordPress.com style administration bar to the top of all content and administration screens for a user who is logged into the system. Though it will be turned on by default, there will be the option of turning it off for those among who prefer things that way. All that will be needed for this is to add the following line near the top of wp-config.php:
define( "WP_SHOW_ADMIN_BAR", false);
The chance to see new additions like those above and be ready for is my main reason for following WordPress development. It's best to be ready instead of being surprised, though it has to be said that the blogging or CMS platform is a very polished one these days.
Removing a column from a MySQL data table
19th April 2010My trying out WordPress 3.0 in advance of its final release has brought me errors on the management page for website links. After a spot of poking around the TRAC, I found that the bug already has been reported and that the cause is an extraneous column in the *_links
table called link_category. The change in taxonomy handling over the years seems to have made it redundant, so I removed the said column from the database using a command like the following from both the MySQL command line and MySQL Query Browser:
alter table database.wp_links drop link_category;
That seems to have made those errors go away, and I hope that their upgrade code takes care of this before WordPress 3.0 is let loose of the general blogging public. Taking out the coding brittleness would do too.
DePo Masthead
6th November 2009There is a place on WordPress.com where I share various odds and ends about public transport in the U.K. It's called On Trains and Buses, and I try not to go tinkering with the design side of things too much. You only can change the CSS and my previous experience of doing that with this edifice while it lived on there taught me not to expect too much even if there are sandbox themes for anyone to turn into something presentable, not that I really would want to go doing that in full view of everyone (doing if offline first and copying the CSS afterwards when it's done is my preferred way of going about it). Besides, I wanted to see how WordPress.com fares these days anyway.
While my public transport blog just been around for a little over a year, it's worn a few themes over that time, ranging from the minimalist The Journalist v1.9 and Vigilance through to Spring Reloaded. After the last of these, I am back to minimalist again with DePo Masthead, albeit with a spot of my own colouring to soften its feel a little. Though I must admit growing to like it, it came to my attention that it was a bespoke design from Derek Powazek that Automattic's Noel Jackson turned into reality. The result would appear that you cannot get it anywhere but from the WordPress.com Subversion theme repository. For those not versed in the little bit of Subversion action that is needed to get it, I did it for you and put it all into a zip file without making any changes to the original, hoping that it might make life easier for someone.
Going mobile
20th October 2009Now that the mobile web is upon us, I have been wondering about making my various web presences more friendly for users of that platform, and my interest has been piqued especially by the recent addition of such capability to WordPress.com. With that in mind, I grabbed the WordPress Mobile Edition plugin and set it to work, both on this blog and my outdoors one. Well, the results certainly seem to gain a seal of approval from mobiReady so that's promising. While it comes with a version of the Carrington Mobile theme, you need to pop that into the themes directory on your web server yourself, as WordPress' plugin installation routines won't do that for you. It could be interesting to see how things go from here, and the idea of creating my own theme while using the plugin for redirection honours sounds like a way forward; I have found the place where I can make any changes as needed. Homemade variants of the methodology may find a use with my photo gallery and Textpattern sub-sites.
A self-hosted online photo album option
16th July 2009When I was perusing a recent copy of Linux Format, I encountered a feature describing a self-hosted alternative to the likes of Flickr: Gallery. From my quick look, it looks fully featured, offering themes and even shopping cart facilities for those who want to sell their wares. The screenshots on the open-source project's website look promising but, for a fuller appraisal, I would need to spend some time trying to bend it to my will. Before anyone mentions it, I am aware that WordPress can be used for photoblogging, but this tool seems to take things a bit further. It's the sort of thing about which I might have wondered, given the pervasiveness of content management systems these days. My own custom-built photo gallery is devoid of a slick back end, hence why Gallery caught my eye, but I'll continue with it and may even get to adding the needful myself.
Take a great leap forward, then consolidate...
12th June 2009While I have been a user of WordPress since late 2006, I only began to start keeping tabs on its development following my hearing news of dramatic changes coming in what became 2.5. Since a pattern developing with more significant changes coming in 2.5 and 2.7 while both 2.6 and 2.8 didn't add too much in the way of upheaval but rather evolved what was already there. With 2.8, theme and widget management got the once over, while there were plenty of other tweaks that polished a well received forbear. The differences between 2.7 and 2.8 are discernible without breaking anything that shouldn't be broken. In short, I rather like the result.
The reaction to 2.5 was mixed, to say the least, and that in part led to the dramatic changes in 2.7, especially regarding the administration interface. Now, I admit to having had doubts about these when I first saw them in development, especially when there was so much chopping and changing during development that stepping back until things settled down became a necessity. Even adding a ticket to the TRAC was problematical, unless you had sight of what was happening behind the scenes, because it became too easy to add an invalid ticket.
With the release of 2.8 into the wild, 2.9 is now on the horizon, and I am inclined to suspect that we might see more considerable changes again. For one thing, there was that interface poll a little while ago, so who knows what impact that may have on what comes next. The structure of the administration screens may not alter that much, but it still leaves changes to colours and icons with the aim of separating navigation from what else is on there, something that doesn't trouble me at all. In fact, I don't see very much wrong with how things are right now, which causes me to wonder if there's any point in making too many changes at all.
The forecasted incorporation of WPMU functionality is a bigger change that would mean the end of WordPress MU as a separate entity, and would concern me more with the amount of under the bonnet re-engineering that would be needed. Add Google Summer of Code projects to this mix and 2.9 looks as if it could be a step change in the spirit of 2.5 and 2.7, if not in feel. Summer 2009 could be very interesting for WordPress, leaving me to hope that it continues to work for me in the way that it does as we move from version to version.
Where's WordPress 2.8?
7th May 2009It now seems that WordPress 2.7 has been an unqualified success. The major changes that were made to the administration screens have been well received, and the grumblings that were extant about 2.5 and 2.6 seem to have dissipated too. Another observation is that security bugs have not been making their presence felt. All in all, it feels very much like assured progress and may explain why 2.8 has been taking its time in coming.
It's now pencilled in for the end of this month and looks as if it will be a polishing of what already works well. It seems to me that most of the changes are behind the scenes, but there is a new widgets interface that should be ever more user-friendly together with an automated theme installation and upgrade facility that is based on what is already in place for plugins (speaking of which, that interface has been tidied too). Another rough edge that has been removed is the whole business of time zones and daylight saving time. In summary, it seems to be a sharpening of a package that already works well anyway. I have been running it on another site without a whimper of drama, so that's probably saying something. Saying that, quite how they are going to get anyone to upgrade is another matter. For one thing, Lorelle VanFossen's overuse of the word "mandatory" cannot be likely to do it...
In a way, the subject of upgrade fatigue brings me to a recent poll run by Automattic's Jane Wells. Quite a number want to stick with what works, while others fancy a change. This split could be tricky to manage and might even encourage some not to upgrade at all and stick with what works for them. After all, there were two episodes of major upheaval last year and I cannot see everyone wishing to see that happen again. Continual evolutionary freshening would suit me better. Thankfully, any talk of changing the administration screens has been left for 2.9 now, and there's always the option of sticking with 2.8 if what is produced becomes a sufficient irritation. Well, it saves a leap to Habari or another alternative anyway...