WordPress.org

Make WordPress Core

Changeset 15778


Ignore:
Timestamp:
10/12/10 19:25:58 (5 years ago)
Author:
ryan
Message:

has_post_format(). see #14746

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r15777 r15778  
    490490 
    491491    return ( str_replace('post-format-', '', $format[0]) ); 
     492} 
     493 
     494/** 
     495 *  Check if a post has a particular format 
     496 * 
     497 * @since 3.1 
     498 * 
     499 * @uses has_term() 
     500 *  
     501 * @param string $format The format to check for 
     502 * @param object|id $post The post to check. If not supplied, defaults to the current post if used in the loop. 
     503 * @return bool True if the post has the format, false otherwise. 
     504 */ 
     505function has_post_format( $format, $post = null ) { 
     506    return has_term('post-format-' . sanitize_key($format), 'post_format', $post); 
    492507} 
    493508 
Note: See TracChangeset for help on using the changeset viewer.