• Hi Dario,

    Instead of using post title as product name, I prefer to use a custom post meta value. I’m using this code on yasr-functions.php but it didn’t work. Could you please advise? Thanks in advance.

    $check_product_rating = get_post_meta( $post_id, 'product_rating', true );
      if ( !empty($check_product_rating))  {
    	$rich_snippet["name"] = $check_product_rating;
    	$rich_snippet["brand"] = $check_product_rating;
    	$rich_snippet["description"] = $review_name;
            }
    	else
    	{
    	$rich_snippet["name"] = $review_name;
    	}
Viewing 1 replies (of 1 total)
  • Plugin Contributor dudo

    (@dudo)

    hi!

    the post meta ‘product_rating’ it’s not used by YASR, how can I help on this?

    Where and how is that code added?
    You should never edit a file ( yasr-functions.php ) because all the edits will be overwritten everytime the plugin is updated.

    That funcion has 2 filters, one at the begin yasr_filter_schema_jsonld and one at the end yasr_filter_existing_schema

    I suggest to hook the last one, and than ovewrite $rich_snippet[“name”]

Viewing 1 replies (of 1 total)
  • The topic ‘Custom post meta for product name’ is closed to new replies.