Of Zen and Computing

How to Disable Captions in WordPress 2.6

Thursday, October 16, 2008

WordPress 2.6 added a new “captions” feature that allows you to place text below images in a blog post. This feature is helpful for some, but others may wonder how WordPress captions can be disabled.

Some people, like myself, can be a little obsessive about their site’s markup — this author skips the WYSIWYG editor and writes all Of Zen and Computing articles in straight XHTML. As such, I noticed the bbcode-esque [caption…][/caption] tags in my blog posts and quickly disabled the feature.

Don’t use the CAPTIONS_OFF constant

You may find some sites recommending that you add define('CAPTIONS_OFF', 1); or define('CAPTIONS_OFF', true); to your wp-config.php file. Do not use this method — it is a temporary fix, and will not work with versions of WordPress after 2.6.1.

Do use functions.php

Turning off WordPress captions requires you place a little bit of code in your theme’s functions.php file. Look for this file in /wp-content/themes/your-theme-directory. If it is not there, create an empty functions.php file and save it in that location.

WordPress forum moderator Otto42 posted the code for disabling WordPress captions. Just add the following to functions.php:

<?php
add_filter('disable_captions', create_function('$a','return true;'));
?>

Categories: Code, Tips & Tricks

Tags: ,

Digg icon StumbleUpon icon del.icio.us icon Facebook icon

Other articles related to this page

© 2006-2009 OfZenAndComputing.com
E-mail Disclaimer | Terms of Service & Disclaimer | Sitemap

Subscription Options
Search Our Archive of How-To Articles and Blog Posts