• Resolved drewnorman

    (@drewnorman)


    Hello,

    I’m having a problem very similar to this issue, which has been marked as resolved without any additional information.

    I have a meta description explicitly set for a specific instance of a CPT, but in the DOM, I’m instead seeing the following:
    Admin only notice: this page does not show a meta description because it does not have one, either write it for this page specifically or go into the [Yoast SEO - Settings] menu and set up a template.

    The rest of the relevant tags appear without a problem.

    Any help is much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Mushrit Shabnam

    (@611shabnam)

    Hi @drewnorman

    First, I added the meta description from WordPress dashboard > Yoast SEO > Settings > Content type > Custom post type [box] in my local site. Please check this screenshot. When I create a box type post, the meta description set from global settings is appearing in the page source. Please check this screenshot.

    Next, I added a bit change in the meta description via Yoast SEO metabox. Please check this screenshot. Once I made the changes on the individual post via Yoast SEO metabox, I can see the description is updated in the page source. Please check this screenshot.

    Can you kindly confirm if I followed the correct steps to replicate the error?

    Thread Starter drewnorman

    (@drewnorman)

    Hello @611shabnam ,

    Thank you for getting back to me so promptly.

    Yes, you have followed the correct steps as I had initially described and it appears to be working for you. However, I’m just now noticing the error only occurs for CPTs that have had their link adjusted via the post_type_link hook, which I think is a pretty strong lead. We currently have a handful of CPTs that use flat URLs (e.g. ‘{domain}/{cpt-slug}’) and we’re utilizing custom routing to infer the post type from the slug, load the correct CPT post, and pass it to the corresponding template.

    So I’m guessing Yoast tries to automatically determine the CPT post for a route and loads its meta description, but because we’re using custom routing, this breaks down. Assuming I’m on the right track as to the source of the issue, the question is how to adjust how Yoast loads a CPT post for a route to support our custom routes.

    I understand this is a much more specific scenario than originally described, but I’m open to any ideas considering how frequently we set up custom routing.

    Plugin Support Maybellyne

    (@maybellyne)

    As much as we hate to say it, your question goes beyond the technical expertise of the Yoast support team. Therefore, we can’t give you a solid answer to your question.

    But we don’t want to leave you empty-handed. Our developer portal at developer.yoast.com has proven helpful to many developers in the past and hopefully will serve you well too.

    Sorry, we can’t be of more help here.

    Thread Starter drewnorman

    (@drewnorman)

    Hi @maybellyne,

    No problem. I understand our setup is a bit complicated.

    For anyone else running into this issue, I was able to load the correct meta descriptions for the various CPTs with the following:

    function adjust_yoast_meta_descriptions($description, $presentation) {
    $meta = YoastSEO()->meta->for_post(get_the_ID());
    return !empty($meta) ? $meta->description : '';
    }
    add_filter('wpseo_metadesc', 'adjust_yoast_meta_descriptions', 10, 2);

    Because by default Yoast uses the current URL to determine the appropriate meta description and any custom routing can prevent proper post identification from the URL alone, the filter above explicitly requests the meta description from Yoast for the current post ID and updates the existing meta description accordingly.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘SEO Meta Description Not Showing for CPT’s’ is closed to new replies.