Pretty permalinks without mod_rewrite

There are still some third-class web hosters who do allow the .htaccess files … and turn off the standard module mod_rewrite. But without mod_rewrite, WordPress cannot use pretty permalinks, right? Wrong!

There’s another directive we can use: ErrorDocument.

ErrorDocument 404 /index.php

This will do almost the same as the rewrite rules WordPress offers. It will not work with caching plugins like W3 Total Cache, it will not catch empty searches and other .htaccess tricks you may want to use. So consider this trick as a temporary solution until you have found a real web hoster.


Advent Calendar – Predefined callback functions for filters

Filters are often used for removing content. For example, if you want to hide the admin bar you can do the following:

function hide_admin_bar() {
    return FALSE;
add_filter( 'show_admin_bar' , 'hide_admin_bar' );

It's a bit tedious to define an additional function just to return "FALSE". Since version 3.0 WordPress provides various functions to shorten the code:

  • __return_true()
  • __return_false()
  • __return_zero()
  • __return_empty_array()

The above code can now be written as

add_filter( 'show_admin_bar', '__return_false' );

Advent Calendar- How to disable comments for WordPress pages in any theme

Usually you don’t need comments on pages. Unfortunately, WordPress doesn’t offer a separate option to leave comments on posts on and turn them off for pages. If your theme calls comments_template(); in its page.php and you don’t want to break automatic updates, you cannot just remove the function call, because it will be overwritten with the next update.

No problem. There’s an hook for that. It’s a filter called … wait for it … comments_template. We can change the path to the comments template here – if haven’t figured that out already. Let’s build a small plugin.

So, what do we do? We hook into comments_template(); and change the path. Our new path should point to an existing file without any HTML output. In this case, we use just our plugin file, because we know it exists and we control the output.

As you may have noticed our plugin file is included two times: First as a plugin, later as a replacement for comments.php. The function_exists() check prevents any You cannot redeclare … errors.

Putting this all together …

<?php # -*- coding: utf-8 -*-
Plugin Name: Disable Comments On Pages
Version:     1.0
Author:      Thomas Scholz
Author URI:  http://toscho.de
License:     GPL
// This file is not called from WordPress. We don't like that.
! defined( 'ABSPATH' ) and exit;

// If the function exists this file is called as comments template.
// We don't do anything then.
if ( ! function_exists( 't5_disable_comments_on_pages' ) ) {
	 * Replaces the path of the original comments template with this
	 * file's path on pages.
	 * @param  string $file Original comments template file path.
	 * @return string
	function t5_disable_comments_on_pages( $file ) {
		return is_page() ? __FILE__ : $file;

	add_filter( 'comments_template', 't5_disable_comments_on_pages', 11 );

Advent Calendar – Only Update The Core – The Fast Way!

Advent Calendar #1Same procedure as every year! Most of our readers already know of our Advent Calendar tradition, which we have every year before Christmas. What exactly an Advent Calendar is all about, that is explained on this post.

We open a door every day, which contains a little gift for our readers, by providing them a WordPress tip or trick each day until December 24th at WP Engineer. So we hope you will be exciting to see what tip, hack or news will be behind the door the next morning. Enjoy a new little WordPress gift every day until December 24th.

Here goes our first door

Since WordPress version 3.2 updating an existing installation is faster. A constant entered in the wp-config.php makes sure that everything in the folder wp-content won't be touched and so are Plugins or Themes, which previously came along in the Core won't be updated or reinstalled.

// Make WordPress core updates only update the core

And tomorrow another door will be open of our Advent Calendar!
Also the hint: if you would like to write a guest post, please send us your topic or content via eMail.