• Resolved Stonehenge Creations

    (@duisterdenhaag)


    How do I get the Yoast meta data to be retrieved outside of the WP loop?

    I need to fetch certain Yoast metas to be echoed to the header, because Facebook and others needs that info, for example, and Yoast does not (yet) output these specific meta tags.

    I have been able to get the data processed in/after the content with this code, where the second line processes the %% variables:

    $yoast_title 	= get_post_meta( get_the_ID(), '_yoast_wpseo_title', true );
    $yoast_title_dc = apply_filters( 'wpseo_title', wpseo_replace_vars( $yoast_title ) ); 

    This works great if I echo the output to the footer, but not in the wp_head. ?? It just echoes an empty field value.

    I need this for the following:
    I have several event pages (city tours) on my blogs. Each (same) tour is organized 5 times a week, so Google needs a (custom) canonical url of course. The standard Yoast output does this and Google loves it.

    But on Facebook it goes wrong. ??
    When I scrape (https://developers.facebook.com/tools/debug/) an event page, it will only display the info of the canonical url and not the actual event. This makes sharing it to Facebook really impossible…

    I tested several things and if I add certain fb: tags, provided by Facebook, it does work while Google just ignores them. But for that I need to put them within the <head> tag.

    Let’s say the actual event (page) is called “City Tour”. That is the original get_title(). With Yoast I change this for use outside of my website to “%%title%% with %%sitename%% on %%event_date%%.”

    How do I echo the altered output to the <head> of is_singular(‘event’)?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support marcanor

    (@marcanor)

    We can’t offer support on custom code (needed to change (core) features of our plugin). Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive for 2 weeks, we’ll mark it as resolved to keep the overview.

    Thank you for your understanding.

    Closed due to inactivity.

    Thread Starter Stonehenge Creations

    (@duisterdenhaag)

    Awful support!!!
    Made me drop Yoast all together.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get Yoast meta outside of the loop?’ is closed to new replies.