• Resolved neotrope

    (@neotrope)


    Hi, been looking all over for a filter or hook; and have also put in ticket with Yoast (I have licenses for both Premium SEO and news SEO addon).

    Basically trying to find the function to add to functions.php to filter out the site name being added to the og:title and twitter:title meta tags…

    e.g.,
    <meta name="twitter:title" content="My Cool Story Title | My Cool Pub"/>

    need to NOT have this added “| My Cool Pub

    I found one bit of code on web, apparently not current, and it ended up just removing the og:title entirely vs truncated out the site name.

    Any help on this from other users would be HUGE help!

    Thanks!

    https://wordpress.org/plugins/wordpress-seo/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter neotrope

    (@neotrope)

    Hi — well just an editorial note, that if you get the PRO version and then expect any kind of actual “support” from YOAST on how to do anything advanced .. forget about it; they don’t show you HOW to do anything, just point you at the API and suggest you hire somebody. Most other PAID plugins do much better with support on common issues like my question above.

    I donate to numerous plugins in the WP community the past 12 years, and most theme authors will help because they actually do the code; while Yoast folk do not (I believe, perhaps incorrectly, it’s outsourced).

    That being said, I did manage to do a Google search, and found some working elements and guessed on the second one, since the so called hook/API list on Yoast website is incomplete (hint: look in the damn plugin code to find it!).

    SO, whining over, for anybody else — HERE is how to do it:

    this would go in your main functions.php file, of course

    function my_opengraph_title( $title ) {
    	$title = get_the_title();
    	return $title;
    }
    add_filter( 'wpseo_opengraph_title', 'my_opengraph_title' );
    
    function my_ogtwitter_title( $title ) {
    	$title = get_the_title();
    	return $title;
    }
    add_filter( 'wpseo_twitter_title', 'my_ogtwitter_title' );
    Thread Starter neotrope

    (@neotrope)

    Welll.. turns out that did *not* work properly, as it causes the og:title and twitter:title to change to post title on all the tag/category page vs simply changing it for posts …

    need to figure out how to modify code to ONLY apply to “posts” but didn’t see any clear docs for the so-called YOAST API to target just post meta data with a function…

    not sure if something like if(is_single()) would work on these … but going to give it a try.

    ( heavy sigh )

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove site name in og and twitter titles?’ is closed to new replies.