Hi there 👋
This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.
I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.
You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.
Cheers!
Thread Starter
MarkJ
(@forusak)
Thanks @gabrielfuentes for tips, I joined Slack.
As I can’t find help with this, I resolved it by allowing function to run only once. It is good enough in this case, but still it is not answering why is it happening.
New code is:
add_filter('post_class', 'first_item');
function first_item($classes)
{
static $foo_called = false;
if (!$foo_called) {
global $wp_query;
if (0 == $wp_query->current_post) {
$classes[] = 'first-item-class';
$foo_called = true;
return $classes;
} else {
return $classes;
}
}
}
I am not closing it as resolved yet, if someone would like to clarify it.
-
This reply was modified 4 years, 11 months ago by
MarkJ.