php 如何在woocommerce商店基页的顶部添加图像横幅
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21086140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add a image banner to the top of the woocommerce shop base page
提问by Duc Nguyen
I am creating simple image banners on the top of each category page of my site (add category header content)
我正在我网站的每个类别页面的顶部创建简单的图像横幅(添加类别标题内容)
I'd like to add an image to the top of the woocommerce shop base page. When I insert an image in the page edit screen, it does not appear. But Woocommerce 2.x can not display the shop base page excerpt (short description) others normal page are all show their short description. How would I go about doing that? I can not find page template of the woocommerce shop page
我想在 woocommerce 商店基本页面的顶部添加一个图像。当我在页面编辑屏幕中插入图像时,它不会出现。但是Woocommerce 2.x不能显示店铺基础页面摘录(简短描述)其他正常页面都显示他们的简短描述。我该怎么做?我找不到woocommerce商店页面的页面模板
Thanks!
谢谢!
http://wordpress.org/extend/plugins/woocommerce/
http://wordpress.org/extend/plugins/woocommerce/
I found it!
我找到了!
Insert into the top of yourtheme/woocommercer/achive-product.php
插入到yourtheme/woocommercer/achive-product.php的顶部
//Check is_shop - Shop base page
// if True then Show Category Header Content of The first Product in Shop base Page
if (is_shop()) {
$args = array('taxonomy' => 'product_cat');
$product_categories = get_categories( $args );
$term_id = $product_categories[0]->term_id;
$content = get_term_meta($term_id, 'cat_meta');
if(isset($content[0]['cat_header'])){
echo do_shortcode($content[0]['cat_header']);
}
}
Hope to help someone! :)
希望能帮到人!:)
回答by Tyler Wiest
I just wrote a plugin that will do all of this for you for free! It allows you to set an banner image and url from the product category archive page.
我刚刚写了一个插件,可以免费为您完成所有这些工作!它允许您从产品类别存档页面设置横幅图像和 URL。
Download it from WordPress http://wordpress.org/plugins/woocommerce-category-banner/
从 WordPress http://wordpress.org/plugins/woocommerce-category-banner/下载
回答by Sunny
Just thought I would share how I accomplished this so easily. On your shop page click "screen options" at the upper right of the page. Checkmark "Exerpt". Scroll down to the Exerpt box. (there will be a new box to type in there.) Here you can type in the url to your image using html. Click update to update your page. Now you will have the image or banner you want under your shop title. I also removed the title "Shop" by simply removing it from my page title on the page where you edit your shop. Then I changed the menu option in menus back to the shop title. Hope this helps someone. It sure would have helped me to know this sooner.
只是想我会分享我如何如此轻松地做到这一点。在您的商店页面上,单击页面右上角的“屏幕选项”。勾选“摘录”。向下滚动到摘录框。(将有一个新框可以输入。)在这里,您可以使用 html 输入图像的 url。单击更新以更新您的页面。现在,您将在商店标题下看到您想要的图片或横幅。我还删除了标题“商店”,只需将其从您编辑商店的页面上的页面标题中删除即可。然后我将菜单中的菜单选项改回商店标题。希望这可以帮助某人。它肯定会帮助我早点知道这一点。

