Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Brandon Kraft

    (@kraftbj)

    Code Wrangler

    Howdy,

    Untested, but this should do it for you: https://gist.github.com/kraftbj/579aa87b63b9921debc1

    This, when it is an individual post will unset the default tag, then change it to the post title, if present, or blank if none, followed by the site’s title from Settings->General.

    Cheers!

    Thread Starter lilacsun

    (@lilacsun)

    Thank you so much!

    For some reason, that left the post title blank for me, so I used this instead which seems to work for me. Thank you again! ??

    function change_the_ogtitle( $tags ) {
        if ( is_singular() ) {
            // Remove the default og:title
            unset( $tags['og:title'] );
    
            $tags['og:title'] = get_the_title() . ' - ' . get_bloginfo( 'name' );
        }
        return $tags;
    }
    
    add_filter( 'jetpack_open_graph_tags', 'change_the_ogtitle' );
    Plugin Author Brandon Kraft

    (@kraftbj)

    Code Wrangler

    Ah, good call. I didn’t have the post global declared and should have used the function myself.

    Thanks for sharing good code ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get blog name to appear in OpenGraph title tag?’ is closed to new replies.