Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Agregar múltiples pestañas para productos específicos a las páginas de un solo producto de WooCommerce

Estoy tratando de mostrar pestañas de productos adicionales en productos específicos usando $post_id . No estoy seguro de si lo hizo bien. de esta manera funciona para otros fragmentos pequeños que he escrito.

Las pestañas de productos funcionan si hago que se muestren en todos los productos, pero quiero limitar algunas a productos específicos.

Mi intento de código:

 add_filter( 'woocommerce_product_tabs', 'artwork_product_tab' ); function artwork_product_tab( $tabs, $post_id ) { if( in_array( $post_id, array( 8125 ) ) ){ // Adds the new tab return $tabs['artwork_guidelines'] = array( 'title' => __( 'Artwork Guidelines', 'woocommerce' ), 'priority' => 50, 'callback' => 'artwork_product_tab_content' ); } $tabs['standard_sizes'] = array( 'title' => __( 'Standard Sizes', 'woocommerce' ), 'priority' => 60, 'callback' => 'standard_sizes_product_tab_content' ); return $tabs; }

¡Cualquier ayuda es apreciada!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

$post_id no se pasa al gancho de filtro woocommerce_product_tabs .

Puede usar global $product & $product->get_id() en su lugar.

Entonces obtienes:

 function filter_woocommerce_product_tabs( $tabs ) { global $product; // Is a WC product if ( is_a( $product, 'WC_Product' ) ) { // Get product ID $product_id = $product->get_id(); // Compare if ( in_array( $product_id, array( 8125, 30, 815 ) ) ) { $tabs['artwork_guidelines'] = array( 'title' => __( 'Artwork Guidelines', 'woocommerce' ), 'priority' => 50, 'callback' => 'artwork_product_tab_content' ); $tabs['standard_sizes'] = array( 'title' => __( 'Standard Sizes', 'woocommerce' ), 'priority' => 60, 'callback' => 'standard_sizes_product_tab_content' ); } } return $tabs; } add_filter( 'woocommerce_product_tabs', 'filter_woocommerce_product_tabs', 100, 1 ); // New Tab contents function artwork_product_tab_content() { echo '<p>artwork_product_tab_content</p>'; } function standard_sizes_product_tab_content() { echo '<p>standard_sizes_product_tab_content</p>'; }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!