Archived topic
How to add link to post on the title in page hero?
9 replies · Started by Ahmed Eid on January 24, 2020
How to add link to post on the title in page hero?
I tried to add this code to add the link on the headline:
add_filter( 'generate_page_hero_post_title', function( $title ) {
if ( is_single() ) {
$title = the_title( sprintf( '<a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a>' );
}
return $title;
} );
It works but outside the page hero framework.
Hi there,
what would be the purpose of adding the link to the post that is currently being displayed?
I used to use it on my sites
Can you link me to a post where i can see the problem?
The title appears outside the page hero
Can you try this code, instead?:
add_filter( 'generate_page_hero_post_title', function( $title ) {
if ( is_single() ) {
$title = the_title( sprintf( '<a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a>', false );
}
return $title;
} );
Thanks, Tom
But
The headline has disappeared after using the code
Sorry about that, can you try this?: https://generatepress.com/forums/topic/how-to-add-link-to-post-on-the-title-in-page-hero/#post-1146240
I am happy
Thank you so much "Tom"
good job
Glad I could help :)