Replacing String in Shortcode
-
I have a few issues with a plugin I’m working with (businessdirectoryplugin.com) with it’s translation.
I’m having a multilanguage site and the plugin has some issues with certain links with the translation.
For example, on the button “Annuaire” (see link to the page) it always redirects to /de/suche/, that’s correct for the german version, but for french it should be /fr/cherche and for italian /it/cerca.
I came up with the idea, that I could replace the concerned strings on the specific translated pages where this issue is present and added this code to myfunctions.php for the french post:
add_filter('the_content', 'filter_post_479'); function filter_post_479($content){ if ( is_singular() && in_the_loop() && is_main_query() ) { global $post; if ($post->ID == 479){ // 479 is post/page ID you have found $string = "de/suche"; //your string to be replaced $replace = "fr/cherche"; $content = str_replace( $string, $replace, $content ); } } return $content; }Unfortunately, that didn’t work.
I think because the plugin is loaded into the site via shortcode, and so the filter the_content doesn’t apply there.The contents post is as following:
<h1>Annuaire</h1> [businessdirectory]Can someone help me out, how I can replace these strings inside of the shortcode or if there is a better way to do this task?
The page I need help with: [log in to see the link]
The topic ‘Replacing String in Shortcode’ is closed to new replies.