Disable Feature Box on a Per-Post Basis

This document is deprecated! The information on this page refers to a Thesis version that is now obsolete. Please visit the Thesis Docs for current documentation.

When you enable the Feature Box in Thesis Design Options, you have the option to show the feature box sitewide – meaning, on every page and post of your site. If you’ve opted to do this, you may still want to disable the Box on specific Posts or Pages. Using a custom field plus a little bit of PHP, you can make it happen.

But before we get to the “magic code”, let’s talk about how Thesis goes about repositioning the Feature Box to a different section of the page, depending on which Placement settings you’ve chosen in Design Options (as you’ll need to rely on this information to make the custom PHP code work correctly for your site).

Thesis takes advantage of its own hooks when inserting the Feature Box within your site, which means that each Placement setting corresponds to a different hook:

  • In your content column and above all posts → thesis_hook_before_content
  • In your content column and after a post → thesis_hook_after_post_box
  • Full-width above content and sidebars → thesis_hook_before_content_box
  • Full-width above header area → thesis_hook_before_header

So, you’ll want to verify which Placement settings you’re currently using, and make a note of the specific hook involved, in order to use it in the code which we’ll talk about now.

Here’s the basic code you’ll want to paste into your custom_functions.php file:

function disable_fbox_single() {
	global $post;
	$no_fbox = get_post_meta($post->ID, 'no_fbox', true);
	if (is_single() && $no_fbox)
		remove_action('thesis_hook_before_content','thesis_feature_box');
}
add_action('thesis_hook_before_html','disable_fbox_single');

Note the remove_action statement in the code, which currently references the Before Content hook – if you’ve selected “In your content column and above all posts” for your Feature Box Placement settings, then you’re good to go — you needn’t make any further changes to the code.

However, if you’ve chosen one of the other three possible Placement settings, you’ll need to change the name of the hook to the appropriate one for your particular selection.

Once you’ve verified that you’re using the correct hook, you’re done with editing custom_functions.php.

The final step is using the appropriate Custom Field which causes the code to be applied: when creating a post (or page) for which you wish to disable the Feature Box, simply create a new Custom Field with a Key of no_fbox and a Value of 1. Publish the post, and the Feature Box will be suppressed for that post on your live site!