I want to add the description in Rich Snippets

#23103
  • Resolved Ahmed Eid
    Rank Math free

    Hello, I salute you for this wonderful work

    – I want to correct this code so that it works with Rich Snippets settings
    – I want to add the description in Rich Snippets

    add_filter( 'rank_math/snippet/rich_snippet_article_entity', function( $entity ) {
                $entity = [
                '@context'         => 'https://schema.org',
                '@type'            => \RankMath\Helper::get_settings( "titles.pt_{$json->post->post_type}_default_article_type" ),
                'headline'         => get_the_title(),
                'datePublished'    => get_post_time( 'Y-m-d\TH:i:sP' ),
                'dateModified'     => get_post_modified_time( 'Y-m-d\TH:i:sP' ),
                'description'      => '',
            ];
    return $entity;
    
    });
Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I am not sure I understand the nature of this request. Does the above snippet work for your site?
    Could you please let me know the kind of errors that are getting reported so that we can help further?

    Looking forward to helping you. Thank you.

    ​​​​​​​

    I want to use ‘@type’ as default
    I want to add a description

    Hello,

    Thanks for getting back to us.

    If you want to maintain the default settings and only change the description then you can make use of the following code instead:

    add_filter( 'rank_math/snippet/rich_snippet_article_entity', function( $entity ) {
                $entity['description'] = '';
                return $entity;
    
    });

    I hope this info helps. Thank you.

    What is placed here $ entity [‘description’] = ‘؟؟؟’;

    HI there,

    I am sorry but we are not on the same page.

    You mentioned in a previous response that you wanted to enter a custom description. The description that you would like to enter will go here.
    Please note that this field is also available on the Rank Math metabox and you can also enter the description on a post by post basis as shown below:
    Article rich snippet

    Let me know if what you are trying to achieve is different. Thank you.

    Thanks Michael Davis but I want it to auto show

    Todd
    Rank Math free

    Hello,

    If you do not enter anything there, it will be picked automatically from your content. You do not need to do anything.

    If that is not what you are looking for, please rephrase your question because it is getting a little bit confusing about what you want to do.

    I’m sorry, I am not fluent in English

    I’m using %excerpt% to show the article description, but when using $entity[‘description’] = ”; this is not able to show

    Thanks for your always support

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Please remove the code on your theme’s functions.php file to allow Rank Math to auto generate the descriptions on the fly.

    Looking forward to helping you. Thank 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 9 replies - 1 through 9 (of 9 total)

The ticket ‘I want to add the description in Rich Snippets’ is closed to new replies.