我想为WooCommerce添加三个自定义标签.我有下面的代码,其中两个显示,但由于某种原因,属性描述选项卡不显示在页面上.不仅数量定价选项卡不显示其描述.我试图将代码的不同部分移动到不同的位置,我已检查代码是否有错误或缺少部分.这是我能得到的尽可能接近.

我的过程基本上是删除我不想要的现有标签,然后按照我希望它们出现的顺序添加新标签.

我有一种感觉,我错过了一些东西.

这是我正在使用的代码:

// WooCommerce Tabs

// REMOVE EXISTING TABS

add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

function woo_remove_product_tabs( $tabs ) {

unset( $tabs['description'] ); // Remove the description tab

// unset( $tabs['reviews'] ); // Remove the reviews tab

unset( $tabs['additional_information'] ); // Remove the additional information tab

return $tabs;

}

// ADD ATTRIBUTE DESCRIPTION TAB

add_filter( 'woocommerce_product_tabs', 'woo_attrib_desc_tab' );

function woo_attrib_desc_tab( $tabs ) {

// Adds the Attribute Description tab

$tabs['attrib_desc_tab'] = array(

'title' => __( 'Desc', 'woocommerce' ),

'priority' => 100,

'callback' => 'woo_attrib_desc_tab_content'

);

return $tabs;

}

// ADD QUANTITY PRICING TAB

add_filter( 'woocommerce_product_tabs', 'woo_qty_pricing_tab' );

function woo_qty_pricing_tab( $tabs ) {

// Adds the qty pricing tab

$tabs['qty_pricing_tab'] = array(

'title' => __( 'Quantity Pricing', 'woocommerce' ),

'priority' => 110,

'callback' => 'woo_qty_pricing_tab_content'

);

return $tabs;

}

// ADD OTHER PRODUCTS TAB

add_filter( 'woocommerce_product_tabs', 'woo_other_products_tab' );

function woo_other_products_tab( $tabs ) {

// Adds the other products tab

$tabs['other_products_tab'] = array(

'title' => __( 'Other Products', 'woocommerce' ),

'priority' => 120,

'callback' => 'woo_other_products_tab_content'

);

return $tabs;

}

// ADD CUSTOM TAB DESCRIPTIONS

function woo_attrib_desc_tab_content() {

// The attribute description tab content

echo '

Description

';

echo '

Custom description tab.

';

}

function woo_qty_pricing_tab_content() {

// The qty pricing tab content

echo '

Quantity Pricing

';

echo '

Here\'s your quantity pricing tab.

';

}

function woo_other_products_tab_content() {

// The other products tab content

echo '

Other Products

';

echo '

Here\'s your other products tab.

';

}

编辑下面LoicTheAztec的回复,这是我的整个functions.php文件.我试过它有没有?>在底部:

add_theme_support( 'builder-3.0' );

add_theme_support( 'builder-responsive' );

function register_my_fonts() {

wp_register_style('googleFonts-OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,700');

wp_enqueue_style( 'googleFonts-OpenSans');

}

add_action('wp_enqueue_scripts', 'register_my_fonts');

function sc_replacecolon( $content ){ return str_replace( '[sc:', '[sc name=', $content ); }

add_filter( 'the_content', 'sc_replacecolon', 5 );

/* WOOCOMMERCE */

add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs', 100, 1 );

function woo_custom_product_tabs( $tabs ) {

// 1) Removing tabs

unset( $tabs['description'] ); // Remove the description tab

// unset( $tabs['reviews'] ); // Remove the reviews tab

unset( $tabs['additional_information'] ); // Remove the additional information tab

// 2 Adding new tabs

//Attribute Description tab

$tabs['attrib_desc_tab'] = array(

'title' => __( 'Desc', 'woocommerce' ),

'priority' => 100,

'callback' => 'woo_attrib_desc_tab_content'

);

// Adds the qty pricing tab

$tabs['qty_pricing_tab'] = array(

'title' => __( 'Quantity Pricing', 'woocommerce' ),

'priority' => 110,

'callback' => 'woo_qty_pricing_tab_content'

);

// Adds the other products tab

$tabs['other_products_tab'] = array(

'title' => __( 'Other Products', 'woocommerce' ),

'priority' => 120,

'callback' => 'woo_other_products_tab_content'

);

return $tabs;

}

// New Tab contents

function woo_attrib_desc_tab_content() {

// The attribute description tab content

echo '

Description

';

echo '

Custom description tab.

';

}

function woo_qty_pricing_tab_content() {

// The qty pricing tab content

echo '

Quantity Pricing

';

echo '

Here\'s your quantity pricing tab.

';

}

function woo_other_products_tab_content() {

// The other products tab content

echo '

Other Products

';

echo '

Here\'s your other products tab.

';

}

?>

php将多个页面写在一个页面,php – 将多个标签添加到WooCommerce单个产品页面相关推荐

  1. php sku添加,php – 在单个产品页面中显示SKU下的自定义字段值

    我正在定制WooCommerce,我想在产品页面中添加和显示自定义文本(条件和品牌). 该头寸位于"库存"或"SKU"元下.我已设法创建并保存自定义字段,但如何 ...

  2. php sku 代码编写,php – 在单个产品页面中显示SKU下的自定义字段值

    您的问题中提供的代码不完整,应该是这样的: // Enabling and Displaying Fields in backend add_action( 'woocommerce_product_ ...

  3. AppStore 新功能解读:自定义产品页面和 A/B Test 工具(iOS)

    一.前言 可能很多开发者还没有意识到,今年 WWDC21 推出 <Get ready to optimize your App Store product page> 是一个重磅功能!因为 ...

  4. 10个WordPress电商产品页面扩展功能

    电商网站的每个组件都在说服潜在顾客进行购买.从您主页上的内容到结帐流程的设计,每个元素都有一个目的--并且可以进行改进. 在这些组件中,可能没有一个比您的产品页面更重要的了.在这些页面上,购物者可以找 ...

  5. Shopify如何在产品页面上显示SKU

    SKU(库存单位)是数字,通常是字母数字,用于帮助识别产品和跟踪库存.如果商店使用SKU,则会为每个单独的产品变型分配一个唯一的编号.您可以通过编辑主题代码在产品页面上显示变体的SKU编号. 在添加任 ...

  6. 在一个请求分页系统中,分别采用 FIFO、LRU和 OPT页面置换算法时,假如一个作业的页面走向为 4、3、2、1、4、3、5、4、3、2、1、5,当分配给该作业的物理块数M分别为 3、4时,

    页面置换算法 题目: 在一个请求分页系统中,分别采用 FIFO.LRU和 OPT页面置换算法时,假如一个作业的页面走向为 4.3.2.1.4.3.5.4.3.2.1.5,当分配给该作业的物理块数M分别 ...

  7. IDEA在jsp页面写out.print()代码报错

    如题,小编以前用myeclipse,eclipse的时候,在jsp里写java代码都是可以的,现在我换成了IDEA,却莫名报错 而且没有代码提示,比如说下图这样的,,虽然运行还是能运行...但对强迫症 ...

  8. php html5 css样式,怎么在html页面写css样式表

    本教程操作环境:windows7系统.html5和css3版,该方法适用于所有品牌电脑. 在html页面写css样式表 1.首先可以直接把css代码写在现有的HTML标签元素的开始标签里面,并且css ...

  9. layui 子页面写弹出框覆盖父页面,以及给弹框中的表单赋值

    咋说呢,因为对 layui 不太熟悉,这个弹出框搞了好久,看了好多解决方案,大致尝试了一下其中几种,在坑中无法自拔...总之终于搞出来了,在这里分享一下我的笔记. 着急的直接 戳这里 看解决代码. 尝 ...

最新文章

  1. 《windows核心编程系列》二谈谈ANSI和Unicode字符集
  2. 搭建java_搭建java开发环境
  3. Linux 的文件权限与目录配置
  4. Android 引用第三方开源库,出现冲突 Manifest merger failed : Attribute application@icon value=...
  5. 股权证明pos记账权是根据不同节点_中币(ZB)说真的,区块链第四期:关于ETH2.0,你需要了解的——PoS...
  6. 再问数据中台 - 数据中台的典型架构是怎样的?
  7. c 语言 数据库 pdf下载,Visual C/C++ 编程精选集锦 数据库及图形图像分册 PDF扫描版[38MB]...
  8. [学习笔记]中国剩余定理
  9. python生成器推导式_python之推导式and生成器表达器笔记及面试坑
  10. 据说每年有四分一的房地产项目烂尾,房子都是预售的钱哪里去了?
  11. Centos:更换为网易镜像源
  12. react native 抖音视频列表页
  13. 开发润乾报表过程:因为内容过多分页导致的这条线
  14. Linux系统的特点有哪些
  15. 中国联通将 900MHz 频段频谱资源重耕用于 5G 系统,更有利用把5G网络覆盖到边远地区的每一寸土地
  16. dreamweaver如何连接mysql_Dreamweaver连接数据库教程(ASP类)
  17. 关于kali连不上网络
  18. SpringSecurity详细介绍RememberMe功能
  19. IE浏览器歇菜之后,建模助手干了这件事
  20. 独立钻石Solitaire算法求解

热门文章

  1. 用MathType编辑带点星号的流程
  2. 转: 常见加密算法分,用途,原理以及比较
  3. 图像的放大与缩小(2)——双线性插值放大与均值缩小
  4. shell脚本之日志拆分和监听
  5. HDLC和 PPP的实验
  6. smarty模板引擎_7-自定义函数
  7. Android IOC模块,利用了Java反射和Java注解
  8. 图结构练习——BFS——从起始点到目标点的最短步数
  9. strcpy函数的使用
  10. Node.js的3m安装法