WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
[resolved] Functions / hooks for including SEO data elsewhere (5 posts)

  1. ModeratoMaestoso
    Member
    Posted 2 years ago #

    Hi everyone,

    Is there a way of including SEO data (title, keywords, description, image etc.) elsewhere in the theme. I'm adding a load of schema.org microdata to my theme, and would like to avoid hacking the core files of the plugin.

    Many thanks,

    Martin

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. Joost de Valk
    Member
    Plugin Author

    Posted 2 years ago #

    Yeah sure, just read the code? :)

  3. ModeratoMaestoso
    Member
    Posted 2 years ago #

    Still reasonably newbie-ish to all this stuff Joost ;)

    This seems to work so far (as a test) for the meta description:

    function custom_seo_info() {
    
    	$metadesc = wpseo_get_value('metadesc');
    
    	$martinsmetadesc = apply_filters( 'wpseo_metadesc', trim( $metadesc ) );
    
    	echo '<meta name="custom-meta-tag-name" content="'.esc_attr( strip_tags( stripslashes( $martinsmetadesc ) ) ).'"/>'."\n";
    
    };

    And then in the template call:

    <?php custom_seo_info(); ?>

    :) Martin

  4. Joost de Valk
    Member
    Plugin Author

    Posted 2 years ago #

    yes that would work :) well done!

  5. ModeratoMaestoso
    Member
    Posted 2 years ago #

    Sorry.... Me again :)

    $metadesc = wpseo_get_value('metadesc');

    works, but fails to take into account the conditionals that are built into the plugin.

    The full code for defining the variable with the conditionals is:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    But it seems a little redundant to duplicate this in a custom plugin... Is there a way of using $metadesc outside the class? It's not defined as a global variable...

    Martin

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic