• Resolved armedandgorgeous

    (@armedandgorgeous)


    Hi,

    im trying to write some code that displays a review if the title (or even product description) contains the word ‘crepe’. I’ve experimented with various terms and tried to get product title various ways but I cant seem to get it to work. I’ll attach one experiment as an example of what im trying to do:

    function crepe_review () {
    	global $product;
    
    	if ( ! $product ) {
    		return;
    	}
    
    	$product_id = $product->get_id();
    
    	if ( term_exists( 'crepe', $product_id ) ) {
    			echo '<p>***</p>';
    		
    	}
    
    }
    
    add_action( 'woocommerce_single_product_summary', 'crepe_review', 34 );

    Ive also tried to use has_term and get_title but I just cant seem to crack it.
    Can anyone help me?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘If term is in title then echo “***”’ is closed to new replies.