WooCommerce商店页面使用我的自定义模板
-
-
也许[WC文档](http://wcdocs.woothemes.com/codex/template-structure/)有一些提示.Maybe [WC documentation](http://wcdocs.woothemes.com/codex/template-structure/) has some hints.
- 0
- 2013-02-23
- brasofilo
-
@brasofilo我已经搜索了文档,但那里没有任何线索...@brasofilo I have searched over the documentation but not got any clue there...
- 0
- 2013-02-23
- NewUser
-
检查[this](http://stackoverflow.com/a/11760129/1287812)是否有帮助.Check if [this](http://stackoverflow.com/a/11760129/1287812) helps.
- 0
- 2013-02-23
- brasofilo
-
是的,我尝试过,但是它显示的是这样的错误:致命错误:无法重新声明show_template()(先前声明为`yes I tried that but it is showing like this `Fatal error: Cannot redeclare show_template() (previously declared `
- 0
- 2013-02-23
- NewUser
-
函数名称有误,请更正.There was a mistake with the function name, just corrected it.
- 0
- 2013-02-23
- brasofilo
-
我没有遇到相同的问题`致命错误:无法重新声明so_9405896_show_template()`nope the same problem with me `Fatal error: Cannot redeclare so_9405896_show_template()`
- 0
- 2013-02-23
- NewUser
-
3 个回答
- 投票数
-
- 2013-03-01
通过回答您的问题,我想告诉您 woocommerce 不会使用您的自定义模板.它将使用自己的模板. 当您要使用 wordpress高级自定义字段插件时,我想告诉您的是,该功能仅在页面上有效,并且发布.因此,由于 woocommerce 不允许使用您自己的自定义模板,因此您无法使用高级自定义字段功能.
现在要做一些不同的事情.只需在要展示产品的地方制作自己的自定义模板即可.然后只需转到站点 http://docs.woothemes.com/document/woocommerce-shortcodes/ 在这里,您可以看到
短代码.plugins/woocommerce/" rel="noreferrer"> woocommerce .在这里,您可以使用自己的自定义轻松显示几乎所有产品.现在,使用这些短代码来展示产品.在这里,您已经实现 woocommerce 使用您自己的自定义模板.现在,由于它是您自己的模板,因此您可以轻松地使用高级自定义字段.明白了吗?如果您无法理解任何事情,请回复我.希望对您有帮助. By going through your question I want to tell you that woocommerce will not use your custom template. It will use its own template. As you want to use wordpress advanced custom fields plugin I want to tell you is that feature only works on the page and post. So as woocommerce will not allow to use your own custom template you can't use advanced custom fields features.
Now just do something different. Just make your own custom template where you want to show your products. Then just go to the site http://docs.woothemes.com/document/woocommerce-shortcodes/ Here you can see the shortcodes for the woocommerce. Where you can easily show almost all products with your own customization. Now use these shortcodes to show the products. Here you have achieved that woocommerce is using your own custom template. Now as it is your own template you can easily use advanced custom fields with this. Is that clear? If any thing you can't understand then reply me. Hope this will help you.
-
- 2013-02-27
我不确定我是否能正确理解您的问题,但这是我尝试复制的问题.
首先,请考虑 WooCommerce文档的这一部分:
如果您要编辑这些模板之一,只需将其复制到主题内的目录中,该目录名为
/woocommerce
,并保持相同的文件结构,例如将/templates/cart/cart.php
移动到themename/woocommerce/cart/cart.php
.复制的文件现在将覆盖WooCommerce默认模板文件.第二,这是复制步骤:
- 使用WP 3.5.1,TwentyEleven 1.5,WooCommerce 1.6.6和AdvancedCustomFields 4.0.0
- 在"阅读设置"(
/wp-admin/options-reading.php
)中将页面"商店"设置为静态首页 - 设置一个ACF字段组,其中包含一个图像字段(
product_tab_banner
),其返回值为"图像对象",并显示在帖子类型"产品"中
解决方案:
- 创建以下文件夹:
/wp-content/twentyeleven/woocommerce/
- 将文件:
/wp-content/plugins/woocommerce/templates/content-product.php
复制到此新创建的文件夹中 - 将您的代码放入此
content-product.php
副本中
$product_tab_banner = get_field('product_tab_banner'); if($product_tab_banner): ?> <div class="nt-highlighted-products"> <img src="<?php echo $product_tab_banner['url']; ?>" alt="<?php echo $product_tab_banner['alt']; ?>" width="<?php echo $product_tab_banner['sizes']['featured_product-width'];?>" height="<?php echo $product_tab_banner['sizes']['featured_product-height'];?>" title="<?php echo $product_tab_banner['title']; ?>" /> </div> <?php endif; ?>
这是产品页面:
这是网站中的结果:
如果您想自定义"商店"页面,请将文件
/wp-content/plugins/woocommerce/templates/archive-product.php
复制到主题的/woocommerce/
文件夹.I'm not quite sure if I understand your problem correctly, but here's my attempt to replicate it.
First, consider this part of WooCommerce documentation:
If you want to edit one of these templates simply copy it into a directory within your theme named
/woocommerce
, keeping the same file structure, e.g. move/templates/cart/cart.php
tothemename/woocommerce/cart/cart.php
. The copied file will now override the WooCommerce default template file.Second, this are the replication steps:
- Using WP 3.5.1, TwentyEleven 1.5, WooCommerce 1.6.6 and AdvancedCustomFields 4.0.0
- Set the page "Shop" as the static front page in Reading Settings (
/wp-admin/options-reading.php
) - Set an ACF Field Group that contains an Image Field (
product_tab_banner
), with Return Value as "Image Object" and to be shown in the post type "Product"
Solution:
- Create the following folder:
/wp-content/twentyeleven/woocommerce/
- Copy the file:
/wp-content/plugins/woocommerce/templates/content-product.php
to this newly created folder - Place your code in this copy of
content-product.php
$product_tab_banner = get_field('product_tab_banner'); if($product_tab_banner): ?> <div class="nt-highlighted-products"> <img src="<?php echo $product_tab_banner['url']; ?>" alt="<?php echo $product_tab_banner['alt']; ?>" width="<?php echo $product_tab_banner['sizes']['featured_product-width'];?>" height="<?php echo $product_tab_banner['sizes']['featured_product-height'];?>" title="<?php echo $product_tab_banner['title']; ?>" /> </div> <?php endif; ?>
Here's the product page:
And here the result in the site:
If you'd like to customize the "Shop" page, copy the file
/wp-content/plugins/woocommerce/templates/archive-product.php
into your theme's/woocommerce/
folder. -
- 2013-03-01
请尝试使用官方的WooCommerce扩展(例如"产品附加组件"( http://www.woothemes.com/products/product-add-ons/).
Please try to replace the plugin you're using with the official WooCommerce extensions like "Product Add-ons" (http://www.woothemes.com/products/product-add-ons/).
在询问问题之前,我想告诉您,我已经在 https://stackoverflow.com/questions/15025213/wordpress-woocommerce-template-file-overiding
我正在使用 WooCommerce 插件来开发网站. WooCommerce一切都很好.根据我的要求,我已经从WooCommerce仪表板将主页配置为商店基础页面,以使我的主页成为商店页面.现在,我的要求是放置一些应从管理端上传的图像,并在图像上显示一些文本.对于该功能,我在Google上进行了搜索,有人建议我使用 WordPress高级自定义字段.我刚刚安装了它.
现在,我看到WooCommerce没有使用我的自定义主题.它使用自己的自定义主题.由于我想使用高级自定义字段插件显示图像和文本,因此我确实需要自己的自定义模板来使用查询图像和文本.然后我再次在Google上搜索了解决方案,并得到了建议,只需将主题的
page.php
复制到woocommerce.php
中,然后替换代码即可:使用
我这样做了,但仍然没有从高级自定义字段中获得我的自定义字段.所以请帮助我.任何建议和帮助将不胜感激.谢谢.
我用于显示图像和文本的高级自定义字段的代码如下:
我正在使用WordPress TwentyEleven主题.