It is a post template that should work for different posts and in different languages. There should be no different templates for different languages. That's why I thought of the following. I compare the loaded url with string and path. If the condition is met, a URL and text will be added to the following link. Since I'm still at the beginning, I'm interested in your feedback and other approaches. Maybe you have any comments. So I can see what I can do better. Please help me so I can learn more. Thank you
var url = window.location.href
var path = window.location.pathname
var output1 = "http://localhost";
var output2 = output1 + path;
$(window).on('load', function () {
if (url == output1 + path) {
$("a.blog-wort").attr("href", "http://localhost/landing1/");
$('a.blog-wort').text('text 1');
} else if (url == output2) {
$("a.blog-wort").attr("href", "http://localhost/en/landing2/");
$('a.blog-wort').text('text 2');
} else if (url == output2) {
$("a.blog-wort").attr("href", "");
$('a.blog-wort').text('text 3');
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a class="blog-wort"></a>