How to create a php variable using WordPress the_title() function

Indeed, the the_title function echoes the title, unless you set the third parameter to false (default true). So you start with this; $title = the_title (”,”,false); Now, $title may contain all kinds of characters that cannot be used in PHP variable names, so we need some sanitization: $title = preg_replace(‘/[^A-Za-z0-9\_]/’, ”, $title); // Removes special … Read more

Woocommerce : Can’t get product info in loop

First of all, get_price_html() outputs html code for product price. To get sale price specifically, use get_sale_price() instead, and get_price() to get regular price. Use Chrome web dev tool to inspect for any php error. The Loop breaks after outputing title, so my guess would be to look for error there.