adding brand name

#247043
  • Resolved Calvin Swanton
    Rank Math free

    hi

    trying to fix issue ‘missing field brand’ in Google Search Console

    tried adding the rank math advised code in my child theme’s functions.php file

    // Add Brand for Products.
    add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    $entity[‘brand’] = ‘Rank Math;
    return $entity;
    });

    on doing so I receive this error
    Parse error: syntax error, unexpected ”Little Miss Twiggie Twinkles;’ (T_ENCAPSED_AND_WHITESPACE) in /home/customer/www/littlemisstwiggietwinkles.co.uk/public_html/wp-content/themes/flatsome-child/functions.php on line 36
    There has been a critical error on this website. Please check your site admin email inbox for instructions.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Anas
    Rank Math business

    Hello,

    Thank you for contacting Rank Math.

    The code that you are using is wrong, a quote is missing after the brand name.

    Add this code to the theme’s functions.php file:

    // Add Brand for Products.
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    $entity['brand'] = 'Rank Math';
    return $entity;
    });

    Replace the “Rank Math” text with your actual brand name then run your website through https://search.google.com/test/rich-results.

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

    Do I just add it at the bottom already have other code in the file?

    <?php
    // Add custom Theme Functions here// Add Brand for Products.
    //Hide Price Range for WooCommerce Variable Products
    add_filter( ‘woocommerce_variable_sale_price_html’,
    ‘lw_variable_product_price’, 10, 2 );
    add_filter( ‘woocommerce_variable_price_html’,
    ‘lw_variable_product_price’, 10, 2 );

    function lw_variable_product_price( $v_price, $v_product ) {

    // Product Price
    $prod_prices = array( $v_product->get_variation_price( ‘min’, true ),
    $v_product->get_variation_price( ‘max’, true ) );
    $prod_price = $prod_prices[0]!==$prod_prices[1] ? sprintf(__(‘From: %1$s’, ‘woocommerce’),
    wc_price( $prod_prices[0] ) ) : wc_price( $prod_prices[0] );

    // Regular Price
    $regular_prices = array( $v_product->get_variation_regular_price( ‘min’, true ),
    $v_product->get_variation_regular_price( ‘max’, true ) );
    sort( $regular_prices );
    $regular_price = $regular_prices[0]!==$regular_prices[1] ? sprintf(__(‘From: %1$s’,’woocommerce’)
    , wc_price( $regular_prices[0] ) ) : wc_price( $regular_prices[0] );

    if ( $prod_price !== $regular_price ) {
    $prod_price = ‘‘.$regular_price.$v_product->get_price_suffix() . ‘ ‘ .
    $prod_price . $v_product->get_price_suffix() . ‘
    ‘;
    }
    return $prod_price;
    }

    remove_action( ‘woocommerce_archive_description’, ‘woocommerce_taxonomy_archive_description’, 10 );
    add_action( ‘woocommerce_after_shop_loop’, ‘woocommerce_taxonomy_archive_description’, 100 );

    // Add Brand for Products.
    add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    $entity[‘brand’] = ‘Little Miss Twiggie Twinkles’;
    return $entity;
    });

    Anas
    Rank Math business

    Hello,

    Yes, add the code at the bottom of the theme’s functions.php file.

    You can also add the code using the Code Snippets plugin.

    Here is a guide for your reference:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/#code-snippets-plugin

    Then clear the website cache.

    I hope this helps. Looking forward to helping you.

    Thanks think I have sorted it out

    Anas
    Rank Math business

    Hello,

    We are super happy that your issue is resolved. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘adding brand name’ is closed to new replies.