Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.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
title.php被wordpress忽略_Php_Wordpress_Woocommerce_Hook - Fatal编程技术网

title.php被wordpress忽略

title.php被wordpress忽略,php,wordpress,woocommerce,hook,Php,Wordpress,Woocommerce,Hook,我正试图从头开始创建自己的woocommerce主题,但我正在为单一产品页面而挣扎。 我的single.php是这样的: <!-- Importation du header --> <?php get_header(); ?> <div id="main-content"> <div id="page-content"> <?php wp_reset_query(); // necessary

我正试图从头开始创建自己的woocommerce主题,但我正在为单一产品页面而挣扎。 我的single.php是这样的:

<!-- Importation du header -->
<?php get_header(); ?>
<div id="main-content">
    <div id="page-content">
        <?php
            wp_reset_query(); // necessary to reset query
            while ( have_posts() ) : the_post();
                the_content();
            endwhile; // End of the loop.
        ?>
    </div>
</div>
<?php get_footer(); ?>

我的content-single-product.php中有一个钩子

<div class="summary entry-summary">
        <?php
            /**
             * Hook: woocommerce_single_product_summary.
             *
             * @hooked woocommerce_template_single_title - 5
             * @hooked woocommerce_template_single_rating - 10
             * @hooked woocommerce_template_single_price - 10
             * @hooked woocommerce_template_single_excerpt - 20
             * @hooked woocommerce_template_single_add_to_cart - 30
             * @hooked woocommerce_template_single_meta - 40
             * @hooked woocommerce_template_single_sharing - 50
             * @hooked WC_Structured_Data::generate_product_data() - 60
             */
            do_action( 'woocommerce_single_product_summary' );
        ?>
</div>

如果我是对的,所有这些行只是调用\plugins\woocommerce\templates\single product中的不同模板部分,但问题是我的产品的标题没有显示,它根本不存在。我尝试在我的_theme\woocommerce\single产品的主题中复制title.php,但它不起作用。请注意,我的主题的function.php是空的,我尝试了一些css代码,看看它是否只是隐藏的,但它不是,看起来我的代码中甚至没有生成标题

如何显示产品的标题

编辑:我尝试将函数添加到我的price.php中,它确实显示了我的标题!看起来我的title.php文件被忽略了,不管我在里面写什么

顺便说一句,title.php很简单:

<?php

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}

the_title( '<h1 class="product_title entry-title">', '</h1>' );

为什么在尝试输出数据之前要重置查询?你不是经常在饭后做吗?。使用
ID()
查看您试图输出的帖子的ID是否正确。另外,您是否确定
content single product.php
正在被
single.php
@virtualLast使用?是的,我知道它被使用了,因为我添加了一些内联注释,它们出现在我的页面中。id也是正确的。奇怪的是如果我加上标题('');对于我的price.php,它在我的页面上输出正确的标题。