the_title_attribute

Definition:
function the_title_attribute( $args = '' ) {}

Sanitize 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.

Parameters

  • string|array $args: Optional. Override the defaults.

Return values

returns:Null on failure or display. String when echo is false.

Source code

function the_title_attribute( $args = '' ) {

	$title = get_the_title();



	if ( strlen($title) == 0 )

		return;



	$defaults = array('before' => '', 'after' =>  '', 'echo' => true);

	$r = wp_parse_args($args, $defaults);

	extract( $r, EXTR_SKIP );





	$title = $before . $title . $after;

	$title = esc_attr(strip_tags($title));



	if ( $echo )

		echo $title;

	else

		return $title;

}

3053

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: