Archived topic
Put a character before and/or after the title
3 replies · Started by Ediciones Desnivel SL on October 20, 2022
I have had no problem in other templates inserting a "-" or a "." at the beginning or end of post titles.
In Generatepress I can't understand how to make this modification. I have looked at the code, the functions...
I have tried using generate_get_the_title_parameters, but it only works for Archive (still changing "if ( ! is_singular()..." for "if ( is_singular()...").
I know generate_after_entry_title, but it's not what I'm looking for, because it puts the character below, not at the end of the title.
Thanks for you the help.
Hi there,
you can do something like this:
add_filter( 'generate_get_the_title_parameters', 'filter_custom_post_title' );
function filter_custom_post_title( $params ) {
if ( is_single() ){
$prefix = 'My prefix ';
$suffix = ' My suffix';
}
if ( $prefix || $suffix ) {
$params = array(
'before' => sprintf(
'<h1 class="entry-title"%1$s>%2$s ',
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : '',
$prefix
),
'after' => sprintf(
'%1$s</h1>',
$suffix
),
);
}
return $params;
}
Thank you very much! 🙌
You're welcome