Site logo

Archived topic

How to add link to post on the title in page hero?

9 replies · Started by Ahmed Eid on January 24, 2020

Viewing posts 1–10 of 10

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?

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;
} );

I am happy
Thank you so much "Tom"
good job

Glad I could help :)

This archived topic is closed to new replies.