I need to add some code to certain Woocommerce product category archies, but only to the first page, neer the paginated archives. Is there a conditional tag for that? I tried
if( is_product_category( array( 'category1', 'category' ) ) || !is_paged )
but it did not work.
You can use woocommerce wc_get_loop_prop()
dedicated function with the 'is_paginated'
and/or 'current_page'
arguments as follow
if( is_product_category( array( 'category1', 'category' ) ) && ( ( wc_get_loop_prop( 'is_paginated' ) && wc_get_loop_prop( 'current_page' ) == 1 ) || ! wc_get_loop_prop( 'is_paginated' ) ) ) {
// Here goes other code
}
Tested and works.