自定义主题单产品页WordPress/WooCommerce

发布于 2025-01-23 12:02:00 字数 412 浏览 4 评论 0原文

我正在构建我的自定义主题,而我的sings.php显示WooCommerce单产品页面,

if ( have_posts() ) {
    while( have_posts() ) {
          the_post();
          the_content();
    }
} 

”在此处输入图像描述

为什么页面缺少 - 标题,评论&面包屑?

I am building my custom theme and my single.php displays woocommerce single product page with

if ( have_posts() ) {
    while( have_posts() ) {
          the_post();
          the_content();
    }
} 

enter image description here

Why is the page missing - title, reviews & breadcrumbs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

北座城市 2025-01-30 12:02:00

WooCommerce有自己的页面模板。单个产品应显示在单产品。php上。您将在自定义主题中创建一个WooCommerce文件夹,并将要编辑的目录和文件复制到主题。

如何覆盖单ploduct.php

如果您想克服单ploduct.php,则会在主题中创建一个WooCommerce文件夹,并将单product.php复制到其中。因此,目录将为yourtheme/woocommerce/smine-product.php。这样,您就会在缺少的功能中挂起所有操作。

这是文档:

Woocommerce has its own templates for their pages. A single product should be showing on single-product.php. You would create a woocommerce folder inside your custom theme and copy the directories and files you want to edit over to your theme.

How to override single-product.php

If you want to custimize the single-product.php, you would create a woocommerce folder in your theme and copy the single-product.php over into it. So the directory would be yourtheme/woocommerce/templates/single-product.php. This way you have all the actions hooking in the functionality you are missing.

Here are the docs:
https://woocommerce.com/document/template-structure/

拥抱影子 2025-01-30 12:02:00
 function mytheme_add_woocommerce_support() {
        add_theme_support( 'woocommerce' );
    add_theme_support( 'wc-product-gallery-zoom' );
    add_theme_support( 'wc-product-gallery-lightbox' );
    add_theme_support( 'wc-product-gallery-slider' );
    }
    
    add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );

请在functions.php文件中添加这个

 function mytheme_add_woocommerce_support() {
        add_theme_support( 'woocommerce' );
    add_theme_support( 'wc-product-gallery-zoom' );
    add_theme_support( 'wc-product-gallery-lightbox' );
    add_theme_support( 'wc-product-gallery-slider' );
    }
    
    add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );

Please add this one in the functions.php file

橙味迷妹 2025-01-30 12:02:00

缺少

add_theme_support('woocommerce');

我的functions.php文件中

I was missing

add_theme_support('woocommerce');

in my functions.php file

小耗子 2025-01-30 12:02:00
function custom_theme_setup() {
    add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'custom_theme_setup' );
function custom_theme_setup() {
    add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'custom_theme_setup' );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文