I would like to filter the titles of my WooCommerce Memberships plans depending in the current language (using PolyLang). The following works on the back end, i.e. I can see that the membership plan title (for membership plan with post_id 3884) changes on /wp-admin/edit.php?post_type=wc_membership_plan
, when I set PolyLang to a language different from English:
function my_the_title( $title, $id ) {
if (pll_current_language( 'slug' ) == 'en') {
return $title;
}
if ( $id == '3884' ) {
return $title . ' - Not English';
}
return $title;
}
add_filter( 'the_title', 'my_the_title', 10, 2 );
The problem is that the above does not work on the front end under /my-account/members-area/
. Here the original membership plan title is used no matter the language. Logging all calls to my_the_title
, I can see that the post 3884 is coming through when browsing back end pages (and I presume that is why it works on the back end), but when browsing front end pages, I do not see post 3884 coming through. I guess the_title
is wrong filter in this particular case, but I can't figure out why and what else to use in that case.
Thanks, Uwe
ps: WordPress 6.3, WooCommerce 8.0.2, WooCommerce Memberships 1.25, PolyLang Pro 3.4.5, PolyLang for WooCommerce 1.8