[wp-hackers] get_theme_support( 'post-formats' )
Chip Bennett
chip at chipbennett.net
Wed Jan 12 16:02:05 UTC 2011
As a follow-up question: if I want to retreive the count of each Post Format
type, what would be the best approach?
Perhaps something like (used inside a foreach, where $postformat is the
slug):
$postformatobj = get_term_by( slug, $postformat, 'post-formats' );
$postformatcount = $postformatobj->count;
Would that work? is there a better way?
Thanks again,
Chip
On Wed, Jan 12, 2011 at 9:38 AM, Chip Bennett <chip at chipbennett.net> wrote:
> That's exactly what I was curious about. Thanks for clarifying, Otto!
>
> Chip
>
>
> On Wed, Jan 12, 2011 at 9:34 AM, Otto <otto at ottodestruct.com> wrote:
>
>
>> On Wed, Jan 12, 2011 at 8:57 AM, Chip Bennett <chip at chipbennett.net>
>> wrote:
>> > $my_theme_supports = get_theme_support( 'post-formats' );
>> > ...should result in, e.g.
>> > $my_theme_supports = array( 'aside', 'gallery' );
>>
>>
>> Actually, it returns an array with an array in it.
>>
>> array(1) { [0]=> array(9) {
>> [0]=> string(5) "aside" [1]=> string(5) "audio" ...
>> } }
>>
>> So you'll want to reference it with the [0].
>>
>> Simple code:
>>
>> $my_theme_supports = get_theme_support( 'post-formats' );
>>
>> if (is_array($my_theme_supports)) $my_theme_supports =
>> $my_theme_supports[0];
>>
>> Now you'll have what you expect it to be.
>>
>> -Otto
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>>
>
>
More information about the wp-hackers
mailing list