[Elementor] Overriding specific word in the page content.

[ad_1]

Hello devs,

**Task**: Override a certain word in the Elementor content. The replacement word is the same, but the first letter must be capitalized.

**Code**:

`function replace_word($content) {`
`if (has_filter(‘widget_text’)) {`
`$content = apply_filters(‘widget_text’, $content);`
`}`
`$content = str_replace(‘Word’, ‘word’, $content);`
`return $content;`
`}`
`add_filter(‘the_content’, ‘replace_word’, 10);`

**Explanation Code above:** This modified function first checks if the widget\_text filter exists, and if it does, it applies the filter to the content. Then it performs the text replacement. This should ensure that the function works for both standard WordPress content and Elementor content.

Unfortunately, this is not the case. Am I using the wrong hooks? I’m aware of the *elementor/frontend/the\_content* hook, but unfortunately this results in the same issue.

Thanks in advance for the help.

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer