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

Authorize.Net

Easily start accepting online payments via credit card and e-check.


(6)
$39

2Checkout

Accept up to eight payment methods, fifteen languages, & twenty six…


(4)
$39

WP Email Styler

Add good looking html template to emails


(3)
$19