It was bound to happen, the very reliable Mesocolumn WordPress theme finally made an entry in a website’s fatal error logs.  I make a habit of examining website error logs, if you have a business with a web department, insist that they regularly scan and check your website error logs or subscribe to a service or has a script that can report 500 errors immediately.

Here was the error that cropped up:

[22-Apr-2016 09:27:05 UTC] PHP Fatal error: Call to undefined function get_theme_option() in /webroot/prolificfutility.com/public_html/wp-content/themes/mesocolumn-child/footer.php on line 119

500 server errors are never pleasant, it’s a fact of life if we don’t dedicate QA time to test, test and then test the sites again and again.  There is a point of diminishing returns of dedicating too much time to testing because that takes time away from web development, you know, actually creating coding solutions?!

Fixing WordPress 500 errors

This was an easy fix, because the error was easy to spot in the logs — get_theme_option function was undefined and there was a condition in the footer that called on it, so I simply wrapped the condition throwing the error first with this check:

if (function_exists('get_theme_options')) {
 // execute other code that was in the child theme here...

It’s not an ideal fix, but since I didn’t have time to investigate further, at least the page would continue loading if the get_theme_options() function was actually deprecated from the theme during a recent update.  It’s all about prioritizing your web development tasks to make sure you are optimizing your code production and in the context of other due dates, projects and considering the ROI of this task, it’s way down on the priority list.  So far down it will probably never be addressed since, truthfully, there are usually much more important and profitable web development tasks to perform.  Perhaps the next update it will fix itself, there’s no harm in doing an extra check to see if the function exists, even if they bring it back.

The more important benefit is that the page continues to load without throwing a fatal error, which is not only bad for SEO, it’s bad for the UX of every visitor and that’s always something that’s top on the priority list!


To create a custom template in WordPress for specific categories based on the slug is not a built-in function.  Not sure why since it makes sense to build this capability without creating a new filter.  This could be plug-in, but it’s so simple, it’s one of those things you wonder why it’s taking so long to be included in the core capabilities.  Who wants to install all those single-purpose plug-ins, anyway?

So if you have a category slug called “news” and you want all your news posts to use this new template, just add this filter to your child theme’s footer.php file.  In this example, you would need to create a template file called “single-news.php” and WordPress will automatically use this to override the theme’s template for that category.

//Gets WP category slug of post and looks for single-[cat slug].php template file:

add_filter('single_template', create_function(

      '$the_template',
      'foreach( (array) get_the_category() as $cat ) {
            if ( file_exists(STYLESHEETPATH . "/single-{$cat->slug}.php") )
                  return STYLESHEETPATH . "/single-{$cat->slug}.php"; }
           return $the_template;' )
);

NOTE: If you’re not using a child theme, read this first, then if you’re still not convinced, use:   TEMPLATEPATH  instead of STYLESHEETPATH for above.  But don’t ever do it that way, every time WordPress gets updated you’ll end up having to make these changes, unless you just like letting code get broken because you’re too insecure of a web developer to want to create new solutions so you’d prefer to just keep fixing things you could prevent from breaking…


Sometimes, I wonder if the WordPress community doesn’t create some over-complication of things just because it can.  I came across the term “texturizing” when I was developing another WordPress plug-in.  I ignored the warning before but figured it warranted a second look.  After all, it sounds like it could affect something on one of our WordPress sites, right?!  What on earth does “texture” refer to in the context of the web?!

I had 5 minutes and I do not like to leave things to chance — hardly a luxury when you’re in charge of a bunch of national websites.  Why haven’t I heard of “texturizing” before?!  I thought.  We technical “experts” have to know more than others, after all.  Our jobs and livelihood depend on it.  I had to find out, so I searched the web and found this link:

https://codex.wordpress.org/Plugin_API/Filter_Reference/no_texturize_shortcodes

At this link, I learned what “texturizing” in WordPress means.  To save you the suffering of visiting its usually out-dated and anemic reference guide, it means replacing normal quotes with fancy quotes.

Really?  File this one away in the “I heard of that but don’t think it’s very important directory” in your mind.  In other words, forget it.  Sorry to even have wasted your time with this one, but in case someone stumbles on it through some miracle of web search sorcery, now you know, now only if we could sound smart saying “is that website texturized properly?!”  At least that could be “fun”.  Notice the quotes around “fun”?!   🙂

Looking for a PHP, Symfony, Magento, WordPress, MySQL expert?  We have you covered!


It’s inevitable when you install Jetpack that some things on your site will need to be re-updated.  I found this out when I installed Jetpack and couldn’t find the footer overrides so the site was showing the “Proudly powered by WordPress” message at the bottom.

Gotta love Jetpack by WordPress‘s “infinite scroll” feature though — and Jetpack in general is great!

After a little digging, I found the solution.  I only wasted another 10 minutes of my life updating something so small but so necessary.  Again.  Don’t you love how the web has turned us all into overly-anal critics paying attention to things that in normal life elsewhere just plain simply wouldn’t matter?  Yes, the line at the footer of the website that no one reads, when did we all turn into such hollow digital echoes of our real selves?…..  🙂

Here’s the code you need to put in your child theme’s function.php file:

add_filter( 'infinite_scroll_credit', 'my_footer_text' );

function my_footer_text() {
return '<a href="http://linkOrNot">Proudly created not by WordPress, or whatever you want to put in here, everyone knows its WordPress anyway....</a>';
}

 


Don’t forget to install CURL after installing PHP. The Symfony PHP framework needs it, WordPress needs it. Most websites running PHP need CURL.

I find something will need it and if your website is going to talk to other websites, you’re probably going to need CURL. Just make it a habit before rebooting after you first install your Apache or other server to run this extra line to grab CURL:

$ apt-get install php5-curl