Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

After adding support for a selection of post formats like this:

add_theme_support( 'post-formats', array( 'aside', 'video' ) );

how can I then get the list of supported post formats back?

I'm building a theme where the user can toggle support for postformat, and I want other admin elements to reflect what post formats the user has configured the theme to support.

so I'm looking for something like

current_theme_supports( 'post-formats'); // outputs boolean

but that outputs just true or false, whereas I want to get an array of the post formats actually registered..

what would be the correct WordPress function to call (or constant/global var) to look at for this?

I want something like this:

get_supported_post_formats(); // out: array('aside', 'video')
share|improve this question
    
I wanted to tag this with theme-support but the tag is not registered, and I can't add new tags.. could an admin consider this as a new tag? –  mikkelbreum Jun 28 '11 at 15:14
    
codex.wordpress.org/Class_Reference/… Formats are a taxonomy..... so can you do something with that? LIke maybe using codex.wordpress.org/Taxonomies#Listing_the_terms –  Rev. Voodoo Jun 28 '11 at 15:21
add comment

2 Answers

up vote 4 down vote accepted

Taken from post_format_meta_box;

if ( current_theme_supports( 'post-formats' ) ) {
    $post_formats = get_theme_support( 'post-formats' );

    if ( is_array( $post_formats[0] ) ) {
        print_r( $post_formats[0] );
        // Array( supported_format_1, supported_format_2 ... )
    }
}
share|improve this answer
add comment

get_theme_support( 'post-formats' ) will return the array of supported formats.

share|improve this answer
    
For some reason the array returned is nested, why is that? $post_formats[0] is the only parent key, so why is it there? –  mikkelbreum Jun 30 '11 at 16:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.