add_filter() inside another add_filter()

I would use do_action instead of add_filter. While similar, you are hooking into an action verse filtering a function. close, but different. function custom_get_availability( $availability, $_product ) { global $product, $bar, $progress; $stock = $product->get_total_stock(); $progress = 100-$stock; $bar = do_shortcode(‘[wp_progress_bar text=”Tickets Sold – ” pc=”.$progress.”]’); if ( $_product->is_in_stock() ) { $availability[‘availability’] = __($bar, ‘woocommerce’); … Read more

Remove image of srcset

If you look in core, that filter is applied like so: $image_meta = apply_filters( ‘wp_calculate_image_srcset_meta’, $image_meta, $size_array, $image_src, $attachment_id ); Instead of using __return_empty_array you need to add a custom function to that filter to remove the srcset size you are trying to get rid of. Something like this. function my_srcset_function($image_meta) { if (!is_array($image_meta)) { … Read more

Calling hooks in functions

You’re on the right path with your add_filter, but this is the right way to implement filters. add_filter( ‘gigpress_related_post_types’, ‘my_related_post_types’ ); function my_related_post_types( $post_types ) { return array( ‘productions’ ); } The hook add_filter must call a function that returns something to pass to the apply_filters in the code you referenced. You should add in … Read more