• Resolved mubashir062

    (@mubashir062)


    Hello,
    firstly thank you so much for such a great theme and plugin.
    i am facing a problem that i need your help with.

    I can see your theme/plugin reviews schema work with the reviews posted. however i am not showing or publishing any kind of reviews but i want to send data to schema from custom field.

    I see the code wp-content/plugins/geodiro/includes/class-geodir-post-data.php from line 2179 to 2189.

    if ( $gd_post->overall_rating ) {
    	$schema['aggregateRating'] = array(
    	"@type"       => "AggregateRating",
    	"ratingValue" => $gd_post->overall_rating,
    	"bestRating"  => "5",
    // @todo this will need to be filtered for review manager if user changes the score.
    	"worstRating" => "1",
    	"ratingCount" => $gd_post->rating_count,
       );
    }

    I have actually got my goal and successfully sending the data by small changes in code as follows

    if ( $gd_post->overall_rating ) {
    	$schema['aggregateRating'] = array(
    	"@type"       => "AggregateRating",
    	"ratingValue" => $gd_post->rrating,
    	"bestRating"  => "5",
    // @todo this will need to be filtered for review manager if user changes the score.
    	"worstRating" => "1",
    	"ratingCount" => $gd_post->rcount,
       );
    }

    the problem i am facing is that whenever gerdirectory plugin update come. it delete the modified code and replace with original.

    is there any way to do it with function.php of the theme. because i already have child theme or something else.

    i don’t want to lose plugin updates too because those are very important. and i can see you guys made very big improvements.

    hope to hear from you soon.

    kind regrds

Viewing 1 replies (of 1 total)
  • Plugin Author Paolo

    (@paoltaia)

    Hi,

    Customization should be done by using hooks/filters via a snippet code plugin (or in functions.php of a child theme). Try following the PHP code snippet to apply the customization you mentioned.

    function gd_snippet_custom_aggregateRating( $schema, $post ) {
    	global $gd_post;
    
    	if ( ! empty( $gd_post ) && ! empty( $gd_post->rrating ) ) {
    		$schema['aggregateRating'] = array(
    			'@type'       => 'AggregateRating',
    			'ratingValue' => $gd_post->rrating,
    			'ratingCount' => $gd_post->rcount,
    			'bestRating'  => '5',
    			'worstRating' => '1'
    		);
    	}
    
    	return $schema;
    }
    add_filter( 'geodir_details_schema', 'gd_snippet_custom_aggregateRating', 11, 2 );

    Let us know how it goes.

    Thanks,

Viewing 1 replies (of 1 total)

The topic ‘Schema Help’ is closed to new replies.