Isso ocorre porque o the_title()
exibe o título da postagem (consulte a documentação vinculada). Use get_the_title()
em vez disso, que retorna o título como uma string.
Editar
Você tem duas opções:
- Use
get_the_title()
para retornar, em vez de fazer eco, o título da postagem - Filtre
the_title
para fazer o eco de uma string personalizada como o título da postagem
Usando get_the_title()
<?php
// NOTE: Inside the Loop,
// or else pass $post->ID
// as a parameter
$post_title = get_the_title();
?>
Usando the_title
filter
<?php
function wpse48523_filter_the_title( $title ) {
// Modify or replace $title
// then return the result
// For example, to replace,
// simply return your own value:
// return 'SOME CUSTOM STRING';
//
// Or, you can append the original title
// return $title . 'SOME CUSTOM STRING'
//
// Just be sure to return *something*
return $title . ' appended string';
}
add_filter( 'the_title', 'wpse48523_filter_the_title' );
?>