• Resolved reza10

    (@reza10)


    Hi

    I am new to wpDiscuz and I have a question about schema markup

    in my website, I have blogpost, products in woo-commerce and educational courses in Learndash with different post types

    I need to make different types of forms for each of these categories and display people star rating in SERP.

    I know default blog post star rating is not showing anymore and cause errors in search console

    but how can I make a schema working review form for my products or my educational courses to show real peoples votes in google

    can I use wpDiscuz for this type of rating

    I saw your guide about adding some codes to theme function.php but it seems to be a sitewide effect

    I need to separate product review schema and course review schema and normal blog post schema

    thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support gVectors Support

    (@gvectorssupport)

    Hi @reza10,

    You should use the code described in this topic.
    https://wpdiscuz.com/community/f-a-q/post-rating-using-aggregate-rating-schema/

    You’ll just need to check the current postid to make it work properly.

    Thread Starter reza10

    (@reza10)

    this is what i found in your website :

    add_filter(‘wpdiscuz_rating_schema’, function ( $rating_schema, $key, $postid ){
    $my_rating_schema = ‘Course’;
    $rating_schema = str_replace(__(‘Article Rating’, ‘wpdiscuz’), $my_rating_schema . ‘ Rating’, $rating_schema);
    return preg_replace( ‘|schema\.org\/Product|i’, ‘schema.org/’ . sanitize_text_field($my_rating_schema) , $rating_schema);
    },11, 3);

    how can I use it for all my courses?
    I need it to work on all of my courses pages and product pages separately

    Plugin Support gVectors Support

    (@gvectorssupportmember)

    Hi @reza10,

    Please try the following code:

    add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
        if (get_post_type($postid) === "custom_post_type") {
            $my_rating_schema = 'Course';
            $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
            return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
        } 
        return $rating_schema;
    },11, 3);

    You just need to change custom_post_type with post types you need.

    Thread Starter reza10

    (@reza10)

    Ok thank you
    now it is working

    but two errors in schema check

    1-description
    A value for the description field is required.

    2-warningprovider
    The provider field is recommended. Please provide a value if available.

    any way to solve it?

    Plugin Author gVectors Team

    (@gvectors-team)

    Hi @reza10,
    As it’s explained in the FAQ topic we don’t support rating schema related issues, that’s why the schema is disabled. There are much information that are out of the comment plugin, and we cannot support it. If you’re going to use the custom code then you should be able to add more information if needed. This is your choice. So enabling the schema means you’re familiar with the code and you can support your future issues.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘product schema on custom post types’ is closed to new replies.