Excerpt as Meta Description instead of CPT Settings

#56645
  • Resolved Anonymous
    Rank Math free

    I’ve included screen shots showing the problem.

    I setup the custom post type Single item description.
    It works fine until it gets overwritten by the excerpt.

    I use the excerpt field for another purpose and cannot have this behavior.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Anonymous
    Rank Math free

    The issue also happens on my CPT category page where the Description overrides the CPT defined settings.

    Anonymous
    Rank Math free

    Upon further investigation, I have found that if the SEO Meta Box is disabled is the SEO Titles & Meta Settings, then the behavior will use the settings saved in Titles & Meta.

    If the box is enabled and the Description on the category/archive page is blank, it will use the settings from Titles & Meta.

    If the box is enabled, and the Description is not empty, then the Description field overrides the settings from Titles & Meta.

    It would be ideal if the settings would not get overwritten unless the %term_description% variable is used in the Meta Box.

    Michael Davis
    Rank Math pro

    Hello,

    Thank you for contacting Rank Math today.

    You can use the following function if you wish to override this to use the Description from Global Setting, if the description is missing in the Post metabox:

    /**
     * Use the Description from Global Setting, if the description is missing in the Post metabox
     */
    add_action( 'rank_math/frontend/description', function( $description ) {
     global $post;
     $desc = RankMath\Post::get_meta( 'description', $post->ID );
    
     if ( ! $desc ) {
     $desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
     if ( $desc ) {
     return RankMath\Helper::replace_vars( $desc, $post );
     }
     }
    
     return $description;
    });

    Hoping this helps you. Thank you.

    ​​​​​​

    Anonymous
    Rank Math free

    Appears to be working Thank you.

    If anything with this surfaces, I will let you know.

    Anonymous
    Rank Math free

    After testing, this fixes the final output, however the change is not reflected in the meta box.

    For example, my excerpt still shows in the empty meta box Description, but the global settings are rendered on final output.

    Michael Davis
    Rank Math pro

    Hello,

    Thank you for the follow up.

    This is expected behavior. The metabox will analyze only page content and hence taking the page content excerpt. This should not worry you, the filter affects the final description output.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Anonymous
    Rank Math free

    The problem with that of course is that the analysis of the SEO page is incorrect.

    Alberto
    Rank Math business

    Hello,

    Yes, I understand your concern. For now, don’t be worried about it, they are just guidelines and meanwhile, all of us would like to get the 100/100 score, since you know your description will be fine at Google’s eyes, it is what really matters.

    But I will submit this suggestion to the devs, so they can check it and maybe implement some change in a future update.

    Looking forward to help you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)

The ticket ‘Excerpt as Meta Description instead of CPT Settings’ is closed to new replies.