Yoast SEO
OG:Title to display posts category (7 posts)

  1. wtoalabi
    Posted 2 years ago #

    I dont know if this is possible, but I have tried using my own limited experience..its not working!
    Thats why I need the help of this wonderful community.
    My site relies more on facebook audience and as such I have automated my posts to be posted on the facebook page..once published.
    However, I need something that is not available in the mainstream...maybe a customized hack.
    I want the og:title of my posts to contain the posts category.
    I have succeeded in adding the category to og:description..but now I want the same category to appear in the titles as well.
    For example:
    og:title = Chicken Chips- Foods
    Foods being the category.
    I want to believe that this is possible...please I need your HELP!!!
    Thanks everyone for taking the time to be of help.


  2. jrf
    Posted 2 years ago #

    Hi wtoalabi,

    There's a filter for that ;-)
    (Hope you used a filter for the og:description 'hack' as well)

    Just add something along the lines of the below to your (child-)theme's functions.php file:

    function my_og_title( $title ) {
    	// Do what you want to the $title, like:
    	// Retrieve the category and add it
    	// $title = $title . ' - ' . $category
    	return $title;
    add_filter( 'wpseo_opengraph_title', 'my_og_title' );

    Oh and in case you didn't know: the filter for the og:description tag is called wpseo_opengraph_desc.

    Hope this helps!


  3. wtoalabi
    Posted 2 years ago #

    Thanks so much Juliete!
    Well, I wouldnt call what I did with the "description" tag a hack..lol
    I just added this to the Posts Type inside Titles & Metas: %%title%% %%page%% %%sep%% %%category%%.
    Now, when I did the same for the title, it shows just the post name and the site name..like this:
    New Post - Site Name
    Then I tried to follow your codes above..same thing.
    Am glad there is a code to even think about...it gives me more assurance that this is possible.
    Thanks so much for your help!!!

  4. jrf
    Posted 2 years ago #

    Hi Wale,

    Definitely not a hack ;-)

    And the code I gave you above is not complete - it currently only receives the title and returns it-. I put it there to give you an idea of how to change the title. That's the part you'll need to program yourself. So in effect, it's just a little code framework to fill in.

    I'm sure you can figure it out ;-)


  5. wtoalabi
    Posted 2 years ago #

    Yeah right...I cant even figure the } function
    if it works right past me...lol
    I cant do this...but I expected the wp seo admin configurations to handle it...since it cant..well, am here!
    You've gat to help PLEASE!!!!
    with Cheers...

  6. jrf
    Posted 2 years ago #

    You've gat to help PLEASE!!!!

    ahum... everyone here who makes the effort to reply to questions is a volunteer....

    Either learn how to do it or may be hire someone ?

  7. wtoalabi
    Posted 2 years ago #

    Well, the weirdest thing seem to be that all I needed to do was to upgrade both Yoast and Jetpack!
    Og:titles are now being pulled from the parameters I set in Yoast!
    But thanks for your offer of help so far...am so grateful!!!
    Now, I can breathe easy.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic