• Resolved wyamout

    (@wyamout)


    Hi first would like to know will the hooks work with the free version?

    We are looking to add reviewedBy to NewsArticle schema

    Doing something like this not working

    function modify_article_schema_output( $schema ) {
        
        // Get the post ID
        $post_id = get_the_ID();
    
        // Get 'article_reviewed_by' field value
        $reviewer = get_field('article_reviewed_by', $post_id);
    
        // Check if 'article_reviewed_by' field is not empty
        if ( !empty($reviewer) ) {
            // Get the reviewer's name and ID
            $reviewer_name = $reviewer['display_name'];
            $reviewer_id = $reviewer['ID'];
            
            // Build the URL
            $url = site_url() . "#/schema/person/" . md5( $reviewer_id );
    
            // Add 'reviewedBy' to the schema
            $schema['reviewedBy'] = array(
                array(
                    'name' => $reviewer_name,
                    '@id' => $url
                )
            );
    
            // Add 'lastReviewed' to the schema
            $schema['lastReviewed'] = get_the_modified_date( 'Ymd', $post_id );
        }
        
        return $schema;
    }
    
    // Add the filter
    add_filter( 'saswp_modify_news_article_schema_output', 'modify_article_schema_output' );
    
Viewing 1 replies (of 1 total)
  • Plugin Author Magazine3

    (@magazine3)

    Hi, Thank you for reaching us. ReviewedBy attribute is available only for WebPage Schema, The property reviewedBy is not recognized by the NewsArticle and Article Schema.

Viewing 1 replies (of 1 total)
  • The topic ‘Modifying Schema Output’ is closed to new replies.