Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP变量在HTML标记之外转义_Php_Wordpress_Woocommerce - Fatal编程技术网

PHP变量在HTML标记之外转义

PHP变量在HTML标记之外转义,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我试图显示wordpress类别的标题,我使用一个标准的woocommerce钩子,但是它的行为非常奇怪,PHP变量在html标记之外逃逸,知道为什么吗 代码如下: add_action ( 'woocommerce_before_main_content', 'ebani_show_category_name' ); function ebani_show_category_name() { if ( is_product_category() ) { $categor

我试图显示wordpress类别的标题,我使用一个标准的woocommerce钩子,但是它的行为非常奇怪,PHP变量在html标记之外逃逸,知道为什么吗

代码如下:

add_action ( 'woocommerce_before_main_content', 'ebani_show_category_name' );
function ebani_show_category_name() {
    if ( is_product_category() ) {
        $category_title = single_cat_title();
        ?>
            <div class='container'>
                <div class='row ebani-title'>
                    <div class='col-xs-12'>
                        <h3 class='title'><?php $category_title ?></h3>
                    </div>
                </div>
            </div>
        <?php
    }
}
add_action('woocommerce_在_main_内容之前,'ebani_show_category_name');
函数ebani\u show\u category\u name(){
如果(是产品类别()){
$category_title=单一类别标题();
?>

single_cat_title
title在默认情况下调用时将
echo
该值。您可以通过传入
false
值来使用第二个参数覆盖该值。如果不添加前缀,只需确保添加默认值
'
(空字符串)作为第一个参数

更新至:

add_action ( 'woocommerce_before_main_content', 'ebani_show_category_name' );
function ebani_show_category_name() {
    if ( is_product_category() ) {
        $category_title = single_cat_title('', false);
        ?>
            <div class='container'>
                <div class='row ebani-title'>
                    <div class='col-xs-12'>
                        <h3 class='title'><?php echo $category_title; ?></h3>
                    </div>
                </div>
            </div>
        <?php
    }
}
add_action('woocommerce_在_main_内容之前,'ebani_show_category_name');
函数ebani\u show\u category\u name(){
如果(是产品类别()){
$category_title=单一类别标题(“”,false);
?>
-返回和显示行为不同。另外,
实际上没有任何作用。您缺少回音。
add_action ( 'woocommerce_before_main_content', 'ebani_show_category_name' );
function ebani_show_category_name() {
    if ( is_product_category() ) {
        $category_title = single_cat_title('', false);
        ?>
            <div class='container'>
                <div class='row ebani-title'>
                    <div class='col-xs-12'>
                        <h3 class='title'><?php echo $category_title; ?></h3>
                    </div>
                </div>
            </div>
        <?php
    }
}
add_action ( 'woocommerce_before_main_content', 'ebani_show_category_name' );
function ebani_show_category_name() {
    if ( is_product_category() ) {
        ?>
            <div class='container'>
                <div class='row ebani-title'>
                    <div class='col-xs-12'>
                        <h3 class='title'><?php single_cat_title(); ?></h3>
                    </div>
                </div>
            </div>
        <?php
    }
}