Archived topic
Using elements for code
1 reply · Started by Ketil on July 26, 2021
Hi. I have been adviced to put code in functions.php, and was wondering if I can use elements for this instead?
This is the code :
if( ! function_exists( 'yith_custom_custom_text_loop' ) ) {
add_filter( 'woocommerce_product_add_to_cart_text', 'yith_custom_custom_text_loop', 20, 1 );
function yith_custom_custom_text_loop ( $text ) {
global $product;
if ( $product->is_type( 'booking' ) && ! $product->is_purchasable() ) {
$text = __( 'Read more', 'your-theme-text-domain' );
}
return $text;
}
}
When adding code in elements, do I need to add open and closing php-tags?
Hi there,
No - that code should be added using one of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/