Detecting Features with ‘current_theme_supports’

Have you ever wanted to design a plugin that works with a specific theme? Maybe you are interested in building a Payments plugin. Maybe you want to build a plugin that provides a bunch of cool widgets. There are lots of features built into WordPress, or WordPress Themes that you could build on top of. However, sometimes its not so easy to detect if a theme supports a certain feature. It wouldn’t make sense to try to run your awesome fantastic widget plugin with a theme that didn’t support widgets!

This is where current_theme_supports comes in handy. Because there are all sorts of features that might or might not be present in a theme, WordPress has made it easy for a theme to tell you if it supports a certain type of feature.

Example

current_theme_supports is super easy to use. Simply use an if statement to test its return value.

if( current_theme_supports( 'app-payments' ) }{
// ..  do something ..
}

This works will all sorts of features, in both WordPress and AppThemes Products. For instance, you can check if a theme supports Payments by testing for ‘app-payments’. You can check for things like Post Thumbnails (‘post-thumbnails’), Custom Backgrounds (‘custom-background’), Custom Headers (‘customer-header’), and Customizable Menus (‘menus’).

Like this tutorial? Subscribe and get the latest tutorials delivered straight to your inbox or feed reader.

Your rating: none
Rating: 4.1 - 9 votes

Popular Add-ons

Profiler for Vantage

Adds a one page author website to your Vantage theme.


(6)
$39

Bazar

A Stunning Child Theme for Classipress 4


(11)
$49

Logic Widgets for Vantage

Quickly and easily add conditional content to your Vantage site including…


(4)
$29