You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

默认WooCommerce页面无内容问题求助:index.php及短码无效

WooCommerce默认页面无内容问题解决方法
  • 确认主题模板结构:WooCommerce需要对应模板支撑商品内容加载,仅含get_header()和get_footer()的index.php无法渲染商品列表。
  • 修改index.php补充内容:
    打开主题根目录下的index.php,在get_header()和get_footer()之间插入以下代码:
    if ( class_exists( 'WooCommerce' ) && is_shop() ) {
        woocommerce_content();
    } else {
        // 保留主题原有内容逻辑
        if ( have_posts() ) :
            while ( have_posts() ) : the_post();
                get_template_part( 'content', get_post_format() );
            endwhile;
            the_posts_navigation();
        else :
            get_template_part( 'content', 'none' );
        endif;
    }
    
    这段代码会自动判断当前是否为WooCommerce商店页面,是则调用官方商品内容渲染函数,否则保留主题原有内容逻辑。
  • 使用WooCommerce官方模板:
    复制WooCommerce插件目录templates/archive-product.php文件到主题目录下新建的woocommerce文件夹中,WooCommerce会优先读取主题内的模板文件,自动加载商品列表。
  • 检查后台设置:
    进入后台WooCommerce > 设置 > 产品 > 显示,确认「商店页面」已选择正确页面,且该页面未被误删或设置错误模板。
  • 排查短码失效问题:
    确保在指定的商店页面中使用[products]类短码,同时确认WooCommerce插件已激活、主题未禁用短码功能。

内容的提问来源于stack exchange,提问作者BORSHIDZE

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 04:34:56