the_title_attribute [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Sanitize the current title when retrieving or displaying.
Works like {@link 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 {@link esc_attr()} before it is passed to the user or displayed. The default as with {@link the_title()}, is to display the title.
Source
<?php
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;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- the_title_attribute - WordPress Codex
Description. Displays or returns the title of the current post. It somewhat duplicates the functionality of the_title(), but provides a 'clean' version of the title for use ...
codex.wordpress.org - WordPress › Support » the_title vs the_title_attribute
Maybe somebody who knows better can confirm this, but if I remember right, the_title_attribute produces a "cleaner" version of the_title that can be placed into ...
wordpress.org - title - Wrap the_title_attribute in a H2 within a Conditional Tag ...
Apr 13, 2011 ... The the_title_attribute() template tag is intended specifically for outputting the Title formatted for use in an anchor tag title attribute.
wordpress.stackexchange.com - How Can I Make WordPress's <?php the_title_attribute(); ?> Render ...
I'm trying to render a WordPress theme that is 100% HTML5 compliant ... Well, just wrap the the_title_attribute() with urlencode() : ... A value of 0 ...
stackoverflow.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- Rasquache on "remove characters from the_title_attribute"
- Rasquache on "remove characters from the_title_attribute"
- saddie.dean on "sorting all posts in alphabetical order"
- fterh on "I believe there is a better way than the_title_attribute()"
- databell96 on "Title attribute PHP code not bring up title text"
- databell96 on "Title attribute PHP code not bring up title text"
- esmi on "Title attribute PHP code not bring up title text"
- databell96 on "Title attribute PHP code not bring up title text"