running multiple hooks
-
Hello, when a user filters by color, I want to dynamically change the Rank Math title, remove the canonical, and modify the meta description accordingly. However, this doesn’t work if I try to make these changes within a function:
add_action('woocommerce_before_shop_loop', 'display_current_filter', 1000);
add_action('woocommerce_before_shop_loop', 'display_current_filter', 1);
function display_current_filter() {
global $wp_query;
if (!empty($wp_query->query_vars['filter_color'])) {
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
return false;
});
}
return false;
}This could work if I modify display_current_filter function, but then I have to call same function at least 5 times (for title, description etc). Is there any way to run these inside a function?
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
if(display_current_filter()) return false;
return $canonical;
});
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.