Hiding Meta Product Price (product:price:amount)

#81892
  • Resolved Progymedia
    Rank Math free

    Hi,

    For a B2B website with price only available for logged in users (and depending of the users), I need to make prices unavailable for public viewing. I saw the code provided here: https://support.rankmath.com/ticket/hide-product-price/

    /**
     * Filter to modify Rank Math product schema data
     * Replace $schema_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
    	unset($entity['offers']['price']);
    	
    	return $entity;
    });

    which removes it from the Rich Snippet, but I’d be looking to also hide the Opengraph meta generated from the price.

    Ex.: <meta property="product:price:amount" content="2.99">

    Thank you!

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

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    You could try using this one:

    /**
     * Allow developers to change the content of specific social meta tags.
     *
     * The dynamic part of the hook name. $network, is the network slug
     * and $og_property, is the property which we are outputting.
     *
     * @param string $content The content of the property.
     */
    add_filter( "rank_math/opengraph/facebook/product_price_amount", function( $content ) {
        return '';
    });

    Looking forward to helping you. Thank you.

    ​​​​​​​

    That did the job!

    Thank you

    Alberto
    Rank Math business

    Hello,

    We are super happy that this resolved your issue. 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.

    Gal
    Rank Math business

    This seems to work too:

    add_filter( 'rank_math/opengraph/facebook/product_price_amount', '__return_false' );

    Hello @gal-5276

    I tried testing your code and it does work too! Thank you so much for sharing this one.

    If you need more assistance with anything else, please do let us know and we will surely help you.

    Thank you.

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

You must be logged in to reply to this ticket.