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

187
Views
Elimine las clases CSS "primera" y "última" del ciclo del producto WooCommerce

Estoy usando un filtro para eliminar las clases "primera" y "última" de la cuadrícula de productos.

Cuando configuro $classes en NULL , las elimina todas, pero mi código debería eliminar solo las dos. Pero eso no funciona.

 add_filter( 'post_class', 'prefix_post_class', 21 ); function prefix_post_class( $classes ) { if ( 'product' == get_post_type() ) { $classes = array_diff( $classes, array( 'first', 'last' ) ); // $classes = NULL; <-- This works strangely enough } return $classes; }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

En su lugar, puede usar el filtro Clase de publicación de WooCommerce.

Entonces obtienes:

 /** * WooCommerce Post Class filter. * * @since 3.6.2 * @param array $classes Array of CSS classes. * @param WC_Product $product Product object. */ function filter_woocommerce_post_class( $classes, $product ) { // array_values() returns all the values from the array and indexes the array numerically. // array_diff - Compares array against one or more other arrays and returns the values in array that are not present in any of the other arrays. $classes = array_values( array_diff( $classes, array( 'first', 'last' ) ) ); return $classes; } add_filter( 'woocommerce_post_class', 'filter_woocommerce_post_class', 10, 2 );
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!