Genius is nothing but great effort applied. – Awa Kenzo

Thesis Theme Code Snippets

If you’re designing Thesis skins for clients on your own test server, you will find yourself doing a lot of redundant work when it comes time to export to a live server. I will show you how to add/remove Thesis elements to save you this headache. Alternativly, you can check out the Thesis Theme User’s Guide for even juicier help.

In custom_functions.php you can paste any of these snippets after the <?php

Last update: 2012.05.12

Template

Add support for Post Thumbnails

add_theme_support( 'post-thumbnails' );

Add more image sizes

add_image_size ( 'featured', 450, 220, true );

Enable WordPress body classes

// Enable WordPress body classes and write them to <body>
add_filter( 'thesis_body_classes', 'custom_body_class' );
function custom_body_class( $classes ) {
$bodyclasses = get_body_class();
	foreach ( $bodyclasses as $bodyclass ) {
		$classes[] .= $bodyclass;
	} 
	return $classes;
}

Register new sidebar widgets

add_action( 'widgets_init', 'custom_register_sidebars' );
function custom_register_sidebars() {
	register_sidebar(
		array(
			'id' => 'new-widget',
			'name' => 'New Widget',
			'description' => 'This is a widget. Drag and Drop things here',
			'before_widget' => '<div id="%1$s" class="%2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>'
		)
	);

Force Full-Width Layout

add_filter( 'thesis_show_sidebars', 'no_sidebars' );

Retrive data from custom fields and metaboxes

// Helper function to echo data from a post/page custom field
function thesis_custom_field( $field ) {
	echo thesis_get_custom_field( $field );
}

// Returns custom field post meta data
function thesis_get_custom_field( $field ) {
	global $id, $post;

	if ( null === $id && null === $post )
		return false;

	$post_id = null === $id ? $post->ID : $id;

	$custom_field = get_post_meta( $post_id, $field, true );

	if ( $custom_field )
		/** Sanitize and return the value of the custom field */
		return stripslashes( wp_kses_decode_entities( $custom_field ) );

	/** Return false if custom field is empty */
	return false;
}

And then use:

<?php echo thesis_get_custom_field( 'custom_field_name' ); ?>

Custom Posts & Pages

Archive page information box

remove_action( 'thesis_hook_archive_info', 'thesis_default_archive_info' );

Custom Homepage Template

remove_action( 'thesis_hook_custom_template', 'thesis_custom_template_sample' );

Default 404 Title

remove_action( 'thesis_hook_404_title', 'thesis_404_title' );

Default 404 Content

remove_action( 'thesis_hook_404_content', 'thesis_404_content' );

Header

Remove default header

remove_action( 'thesis_hook_header', 'thesis_default_header' );

Build a Custom Header

remove_action( 'thesis_hook_header', 'thesis_default_header' );
add_action( 'thesis_hook_header', 'custom_header' );
/**
 * Build custom header
 * 
 * @author Greg Rickaby
 * @since 1.0.0
 */
function custom_header() { ?>
	<p id="logo"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a<>/p>
	<h1 id="tagline"><?php bloginfo('description'); ?></h1>
<?php }

Navigation

Nav Menu

remove_action( 'thesis_hook_before_header', 'thesis_nav_menu' );

Content

Search Box

add_action( 'thesis_hook_before_header', 'thesis_search_form' );

Post Tags

remove_action( 'thesis_hook_after_post', 'thesis_post_tags' );

Post Navigation

remove_action( 'thesis_hook_after_content', 'thesis_post_navigation' );

Previous/next post navigation

remove_action( 'thesis_hook_after_content', 'thesis_prev_next_posts' );

Comments

Comment Link

remove_action( 'thesis_hook_after_post', 'thesis_comments_link' );

Subscribe to Comments plugin compatibility

remove_action( 'thesis_hook_comment_form', 'show_subscription_checkbox' );

Footer

Thesis Attribution (Developer license only)

remove_action( 'thesis_hook_footer', 'thesis_attribution' );

Footer scripts

remove_action( 'thesis_hook_after_html', 'thesis_footer_scripts' );

How To Use These Snippets

If you wanted to move the Thesis Nav Menu below the Header:

First, remove the Nav from the hook, “Before Header”

remove_action( 'thesis_hook_before_header', 'thesis_nav_menu' );

Now, add it back to the hook, “After Header”

add_action( 'thesis_hook_after_header', 'thesis_nav_menu' );

The final syntax in custom_functions.php would look like this:

remove_action( 'thesis_hook_before_header', 'thesis_nav_menu' );
add_action( 'thesis_hook_after_header', 'thesis_nav_menu' );

You can get the full list of Hooks, Elements, and Actions at DIYThemes.com – then print off all the hooks with this handy visual reference: ThesisHooks.com

Greg Rickaby runs on the Genesis Framework

Genesis Framework

The theme you're viewing is the eleven40 Child Theme, which was built on Genesis.

Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go. It's that simple - start using Genesis now!

Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.

Comments

  1. 1
    atlantarealestate :

    Nice list, much appreciated. I'm knee deep in Thesis at the moment. I come from the hand coding side of the world.

    I find it sort of ironic that to make Thesis sing, you have to basically learn a API and to make it really sing, you need to become proficient at a scripting language that resembles SQL queries.

    Not sure all that is easier than standard HTML + CSS + PHP, but apparently a lot of folks do and perhaps I will see the light.

    RM

  2. 2

    It's much more of a framework than theme. Many people don't realize that until AFTER they've paid for it. It's a beast to learn, but if you're coming from the Hand Coding – then Thesis will come easy for you. Once you figure out Hooks & CSS you can pretty much make Thesis do what-ever-you-want!

    Ever wonder why Chris Pearson calls his company, “DIY Themes”? “Do It Yourself” :)

  3. 3

    It's much more of a framework than theme. Many people don't realize that until AFTER they've paid for it. It's a beast to learn, but if you're coming from the Hand Coding – then Thesis will come easy for you. Once you figure out Hooks & CSS you can pretty much make Thesis do what-ever-you-want!

    Ever wonder why Chris Pearson calls his company, “DIY Themes”? “Do It Yourself” :)

  4. 4
    Sushant :

    Any hooks for sidebar. I need to hide sidebar from the home page.

  5. 8
    Alice :

    Hi,

    how would I go about removing the sidebars just from the pages (keep them everywhere else)?

    • 9

      By using the page template “No Sidebars”.

      WP-Dashboard –> Pages –> Edit Page –> “No Sidebars” from the Page Template drop down underneath the “Publish” button.

  6. 10
    Adam :

    Hey, how would I go about removing the RSS link on the navigation bar?

    Thanks
    Adam (www.adamhuxtable.com)

  7. 12

    Lots of places online have mentioned unchecking the RSS feed to remove it from the nav menu, but I want to relocate it. I have done so using the OpenHook plugin for Thesis, but I can get the text to transform to uppercase, but I cannot get the background RSS image to appear, nor can I increase the padding or margin around it through my custom css. Any idea what I might be doing wrong?

    Thanks!

  8. 14

    I cant able to remove thesis footer using
    remove_action(‘thesis_hook_after_html’, ‘thesis_footer_scripts’);
    please help

    • 15
      Sonu :

      This is the correct way improving thesis default footer cheers :)
      remove_action(‘thesis_hook_footer’,'thesis_attribution’);

      • 16
        Sonu :

        not improving it’s removing :D

        • 17

          According to the Thesis Terms of Service, you cannot remove the Thesis Attribution unless you purchase the Developer Option.

          • 18
            Sonu :

            I thought neena had read this in your blog post

            Thesis Attribution (Developer license only)
            remove_action(‘thesis_hook_footer’, ‘thesis_attribution’);

            that is why I have not included that developer license is needed to remove the default footer.

  9. 19

    Absolutely phenomenal, the concept of Hooks. Just two simple lines of code and once You got it, you love it.

  10. 20

    very useful post :) Thanks

  11. 22
    Michael :

    I would appreciate a tutorial on Horizontally scrolling site for Thesis….Thanks!

  12. 24

    How disable comments from wordpress using remove_action ?

  13. 26

    I have one more question about sidebars. Can I disable them for certain browsers (Mobile browsers actually)?

  14. 27

    Hi.
    How would I custom my sidebars on any pages?

Trackbacks

  1. [...] don’t have to replace it. The choice is yours. For a list of removable Thesis objects, click here. That is by no means an exhaustive list, but it should get you started nicely. I understand this is [...]

  2. [...] Thesis 11. How to create a Print friendly Thesis Website 12. The Times v1.1 – Thesis Skin 13. How to Add/Remove Thesis Elements 14. Thesis Skins Currently Available 15. 100 Resources for Thesis WordPress theme users 16. 10 Ways [...]

Leave a Comment

Comment Policy: Thanks for visiting my site! Comments are a permanent record of who you are and what you stand for. Your words are your own, so be nice and helpful if you can. Unhelpful, disrespectful, or spammy comments will be deleted. All comments are read and appreciated, and if you have a question, I will try to respond within a couple days.

*