Support » Plugin: The SEO Framework – Fast, Automated, Effortless. » pogrammatically loading title, description, og data etc.

  • Resolved rubenvreeken

    (@rubenvreeken)


    Is there any way to programmatically retrieve the title, description or any other meta data as generated by the SEO framework?

    I’m trying to add them as extra fields to a REST API endpoint, but I can’t figure out how to get them.

    So far, I can get the title from post meta:
    $title = get_post_meta($object["id"], "_genesis_title")[0];

    And the default title (ignoring post meta):
    $title = the_seo_framework()->title_from_cache();

    But not the fully generated title as it would appear in a theme.
    Same goes for description and the various other meta tags.

    https://wordpress.org/plugins/autodescription/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi rubenvreeken,

    The title function may be checking for if the theme is doing it right, so it can sometimes only partially output the title. For this, you need the meta argument to be true.

    I believe this should work (current page):

    $theseoframework = the_seo_framework();
    
    if ( isset( $theseoframework ) )
    	$title = $theseoframework->title_from_cache( '', '', '', $meta = true );

    If you wish to get it from a specific ID, use this:

    $id = 5;
    
    // e.g. 'category', if filled in it will try to fetch Category ID 5
    $taxonomy = ''; 
    
    $theseoframework = the_seo_framework();
    
    if ( isset( $theseoframework ) )
    	$title = $theseoframework->title( '', '', '', array( 'term_id' => $id, 'taxonomy' => $taxonomy, 'meta' => true );

    If you wish to get the option, please refer to get_custom_field( $field, $post_id ), e.g.:

    $theseoframework = the_seo_framework();
    
    if ( isset( $theseoframework ) )
    	$title = $theseoframework->get_custom_field( '_genesis_title', $id = 5 );

    All output functions in wp_head: GitHub Link.
    Title argument list: GitHub Link.
    Description argument list: GitHub Link.
    Image argument list: GitHub Link.
    Url argument list: GitHub Link

    I hope this helps!

    Thread Starter rubenvreeken

    (@rubenvreeken)

    Thank you for the quick reply Sybre, I’ll look into this and see how this works.

    Plugin Author Sybre Waaijer

    (@cybr)

    Sure thing!
    Let me know if you need any more information or are bumping into something. Have a great day! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘pogrammatically loading title, description, og data etc.’ is closed to new replies.