How to change the title of a woocommerce category / taxonomy page when a filter is applied

I am looking for a solution to come up with a new title for a category / taxonomy page when a filter is applied. Let’s assume we have a webshop offering T-Shirts and we have a product attribute called color. Say we filter on “yellow” as a attribute. What I want to happen is that the current title (T-Shirts) is changed to “Yellow T-Shirts” when the filter is applied. Usually the filters can be extracted from the URL but I am looking for a more elegant solution. Any thoughts on this?

I think I would be a good idea to hook this into Yoast somehow.

add_filter( ‘wp_title’, ‘wpse_258323_title’, 20, 2 );
function wpse_258323_title( $title, $post_id ) {
/* this is where the magic should happend */
return $title;
}

Read more here:: How to change the title of a woocommerce category / taxonomy page when a filter is applied

Leave a Reply

Your email address will not be published. Required fields are marked *