add_theme_support() – a Function to Change the Future of WordPress Theme Development

One relatively new function that could be making a big difference to the future of WordPress theme development is add_theme_support(). The function was introduced late last year with the release of WordPress 2.9. The major current use for add_theme_support() is for conveniently setting thumbnail images for posts and pages. When WordPress 3.0 is released (scheduled for this month) add_theme_support() is also set to be very useful in managing site navigation menus. The scope of these applications and the generality that is implied by the name of the function suggest that add_theme_support() could become a very prominent part of theme design over the next few releases of WordPress.

Using add_theme_support() to Manage Post & Page Thumbnail Images

Available with WordPress 2.9

To take advantage of this functionality, all that is required is one line in functions.php of your theme folder:

add_theme_support( ‘post-thumbnails’ );

Once this line has been added you may notice two differences in the admin section. Firstly, when you are uploading an image, you will now have a link reading ‘Use as thumbnail’. Secondly, there will be a ‘Post Thumbnail’ box when you are editing a post or page.

use-as-thumbnail
post-thumbnail

add_theme_support( ‘post-thumbnails’ ) is especially useful in combination with a function that sets the thumbnail size:

set_post_thumbnail_size( 150, 90 );

which in this case would set the thumbnail size to a width of 150 and height of 90. Additional sizes can be added if you need to use multiple thumbnail sizes within the theme. This is possible through e.g.

add_image_size( ‘mega-thumbnail’, 600, 800 );

You can output these thumbnails on the frontend of your site using the_post_thumbnail() (or e.g. the_post_thumbnail(‘mega-thumbnail’) when there are multiple sizes enabled) within the WordPress loop.

Using add_theme_support() to Manage Navigation Menus

Available with WordPress 3.0

To set up support for managing site navigation menus in the admin (in WordPress 3) you will be able to add the following line to the functions.php file in your theme folder:

add_theme_support( ‘nav-menus’ );

You can then set up a new menu under Appearance > Menus in the WordPress admin and add pages from your site or even from other sites to this menu. There is a convenient drag-and-drop interface for setting the order and hierarchy of the menu items.

The menus you set up here can be added to the front end of your site using the wp_nav_menu() function in your template files.

menu-management

Meet our team?

Find out more

Interested in working with us?

Get in touch