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 add theme support()   a Function to Change the Future of WordPress Theme Development
post thumbnail add theme support()   a Function to Change the Future of WordPress Theme Development

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 588x338 add theme support()   a Function to Change the Future of WordPress Theme Development



Related Posts

  • Using Short Codes to Easily Format WordPress Page Content

    Custom short codes can be extremely useful towards setting up a conveniently manageable WordPress theme design. Since WordPress 2.5, there has been in-built support for creating custom short codes using the add_shortcode() function.A Basic add_shortcode() ExampleIn the example below I have used the short code [go] (square brackets are always included as part of a [...]

  • Finding Post and Category IDs in WordPress

    To take full advantage of all the WordPress template tags and functions it is often required to use post IDs and category IDs. These values can be found conveniently in the WordPress admin area, without needing to refer to the database.Finding a WordPress Post IDTo find the ID of a particular post or page in [...]

  • Image Editing in WordPress

    The release of version 2.9 provided WordPress users with some very useful additional image editing capabilities. In the following article we will look at some of the new options for reversing, rotating, cropping and resizing images.When you are editing a page or post, a row of tools for uploading additional files is available just above [...]

  • Adding PDF Links to WordPress Posts and Pages

    Linking to a pdf can, in many cases, be a very convenient way to add content to your site. We often find that clients will want to add menus, brochures, instructions etc. that may be most effectively viewed, shared or printed in pdf format. Uploading a pdf and adding a link in your site’s content [...]

  • Embedding YouTube Videos, Flickr Images and more in WordPress 2.9

    WordPress 2.9 has greatly increased the ease of embedding videos, images and other types of content. You are now able to display videos on your site from, for example, YouTube simply by entering the url of the YouTube video as plain text in a WordPress page or post. It is also possible to similarly embed [...]

Find out more about Juno style Wordpress web design
Find out more about Juno style Magento web design

Return to web design news.

Leave a Comment