Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Europe/Tirane (GMT+02:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by Marsel Nikolli 1 year, 2 months ago.

Assisted by: Marsel Nikolli.

Author Posts
April 5, 2024 at 11:39 am #15487801

jonG-5

Tell us what you are trying to do?

Is there any documentation that you are following?

Is there a similar example that we can see?Hello!

I would like to add a text and a button at the top of all my already published posts, and I would like that text to be translated and displayed in the appropriate language.

Is there a simple way to do this? I have the plugin "Quick Adsense ", which allows me to insert parts of a code/text in a simple way (for example to insert something at the beginning of the post, at the end of the post, etc). I have tried to put this embedded code in one of the sections of the plugin:
<font size="4" color="black">
Text testing:
<?php _e( 'test-string', 'my-domain' ); ?></font>

Then I scanned the theme and also the plugin from WPML but it doesn't show the string to translate.

What am I doing wrong, is there a faster way to do it?

Thank you very much!

What is the link to your site?

April 5, 2024 at 12:38 pm #15488211

Marsel Nikolli

Hi,

Thank you for contacting WPML Support, I will gladly help you.

You would need to put the code of the string/s you need to place the code in your theme template file, the plugin "Quick Adsense" allows you to insert ads code which is called and loaded on the website after the page is loaded, which is different from the way how the WPML strings work.

Try adding your custom string code to the theme template file (generally single.php), after that scan the theme again for strings.

Let me know if that works out for you.

Regards,
Marsel

April 6, 2024 at 7:20 am #15490255

jonG-5

Thank you very much for the answer!

But once I put the code in the theme, how do I insert it into the Quick Adsense plugin?
Could you give me an example of how to add some text please?
What I should put in the theme and then how to reference it.

Thanks a lot!

April 8, 2024 at 9:21 am #15493257

Marsel Nikolli

Hi,

The code that should be put in the theme template file is:

<?php _e( 'test-string', 'my-domain' ); ?>

* Depending on the logic your theme is built it might require elaboration or more advanced coding in order to properly function.

You can style that text using CSS code on your theme's style.css file.

* You should not insert template code using the plugin "Quick Adsense", the plugin should be used to insert only AdSense code and not custom PHP code.

You can find more detailed information on what you need to achieve in this link:
https://wpml.org/documentation/support/translating-the-theme-you-created/

Please note we can not support or debug custom-coded solutions as per our policy, we will do our best to suggest a correct approach but if you need custom coding I suggest using WPML contractors' service: - https://wpml.org/contractors/

I hope the information provided was helpful and thank you for understanding.

Kind regards,
Marsel

April 8, 2024 at 11:09 am #15493800

jonG-5

Thanks for the answer! I understand that I have to add that to the template.

But after that, how do I insert it into the Quick Adsense plugin? I mean, how do I reference that from quick adsense? That's what I don't understand.

I hope you can clarify this for me.

Looking forward to your reply.

Thank you!

April 8, 2024 at 11:35 am #15493883

jonG-5

Hello again! I have tried to add the string txt to the theme template and I can see now in WPML.

As I told you in my previous message, the thing I need to know is how to reference this text, so I can display it on my page (from Quick Adsense or any other place).

I have looked at the documentation but I have not seen clearly how to do it. I have seen the option to use the following:

<?php
load_theme_textdomain('my-domain', get_template_directory() . '/languages');
?>

But only with that I don't see that it loads the text, so I think I'm doing something wrong and I don't know how to reference it.

I hope you can help me.

Thanks!

April 8, 2024 at 2:41 pm #15494968

Marsel Nikolli

Hi,

As I mentioned in my previous reply, the plugin "Quick Adsense" is not for adding custom code/functions to the website through it, as mentioned on their official website: "Quick Adsense is an Ads management WordPress plugin."

---

The code:

<?php
load_theme_textdomain('my-domain', get_template_directory() . '/languages');
?>

Is not related to your case, that code is used if you are coding a custom plugin.

---

The code that should be added on your theme's file is:

<?php _e( 'test-string', 'my-domain' ); ?>

* The code should be placed exactly where you want the text to appear (ex: before the title, or before the content) directly on the file and not through the plugin "Quick Adsense".

After, scan your theme from WPML -> Theme and plugins localization, and after the scanning is finished, the string should appear on WPML -> String Translation, where you can then translate the string and it should appear translated on your website.

I hope this information is helpful.

Kind regards,
Marsel

April 8, 2024 at 6:03 pm #15495761

jonG-5

ohhh what a pity, the thing is, if I can't use "quick adsense" (which was just an example), is there any other plugin or tool that I can use in a simple way, to put a text like this at the beginning of every post, at the end of every post, etc?

Do you have any suggestion or recommendation for that need? I think it's something relatively simple so I imagine there will be simple options

So that it can be inserted without having to add it hardcoded into the wordpress theme, which is not something advisable in the long term (updates, etc).

April 9, 2024 at 8:14 am #15497302

Marsel Nikolli

Hi,

Putting text at the beginning or the end of every post should be easily manageable using the code example directly in the theme file. I suggest you try using a child theme to prevent any overwrite from any update/upgrade of the theme to all the custom code you might use.

There should be different WordPress plugins that offer adding snippets of code and custom code to themes. Unfortunately, I don't have any recommendations/suggestions for any plugin or tool that might be able to achieve what you want.

Thank you for understanding and let me know if you have any other questions.

Kind regards,
Marsel

The topic ‘[Closed] Translate custom text on all the posts’ is closed to new replies.