Filter to change Front-end Schema data

  • Hi,
    How can I change this filter to shema type “Article” and article type “News Article”. I would appreciate if you can give me the working code. Thank you.

    **
    * Filter to change the schema data.
    * Replace $schmea_type with schema name like article, review, etc.
    * @param array $entity Snippet Data
    * @return array
    */
    add_filter( “rank_math/snippet/rich_snippet_{$schema}_entity”, function( $entity ) {
    return $entity;
    });

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math today.

    The following is a sample application. Please test and let us know how it goes.

    **
     * Filter to change the schema data.
     * Replace $schema_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_article_entity", function( $entity ) {
     $entity['article'] = [
             '@type'    => 'News article',
         ];
     return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.