简体   繁体   中英

Add span HTML to woocommerce shop title

How can I add a HTML span to the woocommerce shop title? I have this function to change the shop title to menu but I need to add a
and a span. When I add the html I get an error

add_filter( 'woocommerce_page_title', 'woo_shop_page_title');
       function woo_shop_page_title( $page_title ) {
                  if( 'Shop' == $page_title) {
                               return "Menu<br><span id="chinese">家庭晚餐</span>";                         }
        }

The double quotes used for the ID attribute of the span tag are breaking your string. Either escape them or switch to single quotes.

Single quote example:

return 'Menu<br><span id="...';

Escaping example:

return "Menu<br><span id=\"...";

Documentation: http://php.net/manual/en/language.types.string.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM