I'm trying to echo text with special tags "h5" So I added this code inside function.php to echo the short description under each product
add_action( 'woocommerce_after_shop_loop_item', 'woo_show_excerpt_shop_page', 5 );
function woo_show_excerpt_shop_page() {
global $product;
echo $product->post->post_excerpt;
}
It works but it echo all the text
So I edited the code to only pick up h5 tags
add_action( 'woocommerce_after_shop_loop_item', 'woo_show_excerpt_shop_page', 5 );
function woo_show_excerpt_shop_page() {
global $product;
//pick up only h5
$html = '<h5></h5>';
$dom = new DOMDocument();
$dom->loadHTML( $html );
echo $dom->getElementsByTagName("h5")->item(0)->textContent;
}
Now my problem is the text doesn't show up at all! What I'm doing wrong?