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:
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 );

Replace p-Tag on Images in Content of WordPress

Personally I think the use of HTML5 makes sense and I like the new possibilities, also in the field of semantics. WordPress has a feature on delivering content that come from the editor – setting breaks and paragraphs. Since forever WordPress is the reason for that, not TinyMCE and the same applies to the integration of images or other elements of this kind. In order to use HTML5 in a perfect way I had to replace the p-Tag with the figure-Tag and so is this small filter was created.
Continue reading …

How to Add and Deactivate the new Feature Pointer in WordPress 3.3

With WordPress version 3.3 comes with the Feature Pointer a well-known idea from other tools. We know this for example from Gmail or Google Doc where they notice you of new features, in which they point with bubbles to these new features. In WordPress 3.3, the Admin Bar has been redesigned successfully - I think - and this is the first time the feature pointer points to it.

Continue reading …

Change the Search-URL of WordPress

With WordPress it is easy to activate readable URLs. Only the search page is not affected by the setting yet, it comes with the syntax ?s as default. But there is a solution to change the URL as you wish.

The following example shows that even if you have permalinks activated, that the URL for the two searchterms wordpress and consulting looks like this: With a little function, which communicates with the redirect, you can adjust the URL. In my case the URL with the two searchterms look like this with the following function:
Continue reading …