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(

      '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…

To enable shortcodes in WordPress excerpts you have to add this to your active theme’s (hopefully a child theme) functions.php file:

add_filter( 'the_excerpt', 'shortcode_unautop');
add_filter( 'the_excerpt', 'do_shortcode');

I recently ran into some issues with a heavily customized WordPress site.  Something was overriding something else somewhere, somehow...

The dreaded “find the problem then traverse back through the code” solution again raised its ugly head.  Oh, the futility, you time-sucking code bug.  Why didn’t the previous developer leave more DOCUMENTATION?!!!!!

Sometimes, you can at least speed up the “backtracing” involved by using more debugging tools that are available when the regular standby, WP_DEBUG constant doesn’t quite cut it for you.

To learn more, go the the Debug Bar WordPress page.  It helped, then when you resolve the problem, just deactivate the plug-in!

– Aaron Belchamber

To allow shortcodes in your WordPress category pages, just go into your active theme’s function.php and add:

add_filter( 'term_description', 'shortcode_unautop');
add_filter( 'term_description', 'do_shortcode' );

To tighten security of your WordPress site, you can disable users’ ability to edit your theme and plug-in files. After all, isn’t that what your web development team should be doing? How are you capturing updates to your site’s files if you allow this and you don’t commit changes to the code repository? It’s never a good idea to alter code through this editor, except for really small sites with a single admin user who is determined to do things on his or her own.

Just simply place this snippet inside your WordPress’s wp-config.php file to deactivate the file editing features in your WordPress admin section: