• Resolved gentheme

    (@gentheme)


    I am trying to get the Meta Description created by this plugin. Working for Yoast and Rank Math, but nothing comes in the Frontend for All in one SEO plugin. I even entered a description on Meta Description box of the plugin in the post.

    <?php$post_id = get_the_ID();// Check for Yoast SEO description

    $post_description = get_post_meta($post_id, '_yoast_wpseo_metadesc', true);// If Yoast SEO description is not available, check for Rank Math description

    if (empty($post_description)) { $post_description = get_post_meta($post_id, 'rank_math_description', true);}// If Rank Math description is not available, check for All in One SEO description

    if (empty($post_description)) { $post_description = get_post_meta($post_id, '_aioseop_description', true);}// Display the post description if available

    if (!empty($post_description)) { echo '<p class="pDesc">' . esc_html($post_description) . '</p>';}?>

    I am developing a WordPress theme, so this is required for users who want to display the meta description for human visitors. Please help.

    • This topic was modified 2 months ago by gentheme.

    The page I need help with: [log in to see the link]

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

    (@arnaudbroes)

    Hey @gentheme,

    Our meta data is stored in a custom table. You can get it like this –

    if ( function_exists( 'aioseo' ) ) {
    $metaData = aioseo()->meta->metaData->getMetaData( $postId );
    $description = $metaData->description;
    }

    That being said, I recommend simply calling wp_head in your theme’s header so all of these plugins, including ours, can automatically output all of their information for you.

    Thread Starter gentheme

    (@gentheme)

    Thank you. But output also includes the #post_excerpt like:

    <p class="pDesc">#post_excerpt This is AIO SEO description.</p>

    For now, i have solved it using replace method.

    // If Yoast SEO and Rank Math descriptions are not available, check for All in One SEO description
    if (empty($post_description) && function_exists('aioseo')) {
    $metaData = aioseo()->meta->metaData->getMetaData($post_id);
    $post_description = $metaData->description;

    // Remove #post_excerpt if it is present
    $post_description = str_replace('#post_excerpt ', '', $post_description);
    }
    Plugin Author arnaudbroes

    (@arnaudbroes)

    You can call aioseo()->tags->replaceTags( $description ); to let our plugin replace all smart tags that are used.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.