wpseek.com
A WordPress-centric search engine for devs and theme authors
the_title_attribute › WordPress Function
Since2.3.0
Deprecatedn/a
› the_title_attribute ( $args = '' )
Parameters: |
|
Returns: |
|
Defined at: |
|
Codex: |
Sanitizes the current title when retrieving or displaying.
Works like the_title(), except the parameters can be in a string or an array. See the function for what can be override in the $args parameter. The title before it is displayed will have the tags stripped and esc_attr() before it is passed to the user or displayed. The default as with the_title(), is to display the title.Related Functions: the_title_rss, get_language_attributes, the_title, language_attributes, wp_filter_oembed_iframe_title_attribute
Source
function the_title_attribute( $args = '' ) { $defaults = array( 'before' => '', 'after' => '', 'echo' => true, 'post' => get_post(), ); $parsed_args = wp_parse_args( $args, $defaults ); $title = get_the_title( $parsed_args['post'] ); if ( strlen( $title ) === 0 ) { return; } $title = $parsed_args['before'] . $title . $parsed_args['after']; $title = esc_attr( strip_tags( $title ) ); if ( $parsed_args['echo'] ) { echo $title; } else { return $title; } }