WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: WordPress SEO by Yoast] Functions / hooks for including SEO data elsewhere

[Resolved] [Plugin: WordPress SEO by Yoast] Functions / hooks for including SEO data elsewhere

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Joost de Valk
    Member

    @joostdevalk

    Yeah sure, just read the code? 🙂

    ModeratoMaestoso
    Member

    @moderatomaestoso

    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

    Plugin Author Joost de Valk
    Member

    @joostdevalk

    yes that would work 🙂 well done!

    ModeratoMaestoso
    Member

    @moderatomaestoso

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] [Plugin: WordPress SEO by Yoast] Functions / hooks for including SEO data elsewhere’ is closed to new replies.