• Resolved vtrn

    (@vtrn)


    I have this in my debug log for a long time:

    [17-Feb-2024 07:17:34 UTC] PHP Notice: Undefined index: @type in /home/vtrn/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/schema/class-frontend.php on line 107 [17-Feb-2024 07:17:34 UTC] PHP Notice: Undefined index: @type in /home/vtrn/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/schema/class-frontend.php on line 180

    I applied some customizations to canonical, schema or page titles with using rankmath codes
    Could the problem be from here?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @vtrn,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    The PHP Warning that you are seeing is caused by an invalid schema markup. If you have added a custom schema for a particular page, then you can use the bulk action to add the default schema on this page and Rank Math will automatically remove all other invalid schema from there: https://rankmath.com/kb/bulk-editing-in-rank-math/#set-schema-markup-to-default-type and then, you can add back the correct schema again and see if that resolves the issue.

    If it doesn’t, let us know here so we can debug this issue further.

    Looking forward to helping you.

    Thread Starter vtrn

    (@vtrn)

    Hi, I found the problem.
    I have disabled the schema of products belonging to a specific category using the following code:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function ($data) {
        $term_ids = array();
        $product_cats = wp_get_post_terms(get_the_ID(), 'product_cat');
        foreach ($product_cats as $product_cat) {
            $term_ids[] = $product_cat->term_id;
        }
        $exclude_category_ids = array( 1665, 1668);
        if (array_intersect($exclude_category_ids, $term_ids)) {
            return false;
        }
        return $data;
    } );

    And when I open a product in these categories
    This error occurs
    How can I avoid this error?

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @vtrn,

    That filter is used to modify the Schema data. You shouldn’t use that to remove a Schema type completely. Please use the following filter instead:
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) { if(is_product()) { $term_ids = array(); $product_cats = wp_get_post_terms(get_the_ID(), 'product_cat'); foreach ($product_cats as $product_cat) { $term_ids[] = $product_cat->term_id; } $exclude_category_ids = array( 1665, 1668,); if (array_intersect($exclude_category_ids, $term_ids)) { unset($data['richSnippet']); } } return $data; }, 99, 2);

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘log’ is closed to new replies.