WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Get the custom description in page (3 posts)

  1. dadone
    Member
    Posted 1 year ago #

    WordPress version:3.5.1
    WordPress SEO version:1.4.7

    I did this:
    Added in functions.php the following function:
    function set_desc(){
    if(is_page()) {
    //Method 1
    $object = new WPSEO_Frontend();
    $metadesc = $object->metadesc(false);
    //Method 2
    //$metadesc = wpseo_get_value('metadesc');
    return $metadesc;
    } else {
    return 'Default description';
    }
    }
    add_filter('wpseo_metadesc', 'set_desc');

    I expected the plugin to do this:
    I expected the plugin to get the custom description I wrote in the Meta Description field inside every page.
    Instead it did this: break the site. I've tried with both methods, none worked.

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

  2. dadone
    Member
    Posted 1 year ago #

    Nvm, I've fixed.

    Solution:

    if(is_page()) {
    global $post;
    $metadesc = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true);
    return $metadesc;
    }

  3. DoZ
    Member
    Posted 1 year ago #

    GOOD GOD!! :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.