Tired of manually changing the dates on your website every year? Then I've got just the thing for you.
With a simple 4 lines of PHP code, WordPress automatically sets the current year. Provided that your server's time is set correctly. However, I would assume that this is the case.
2 einfache Schritte zur automatisch aktualisierten Jahreszahl
1a. Füge diesen Code in deine functions.php ein (meine Empfehlung)
The best way to do this is to use a Child themewhich I have described in more detail in this blog post.
1b. Insert this code with the plugin code snippet
If you are not so familiar with the WordPres folder structure and PHP, you can also implement this code risk-free via code snippets. However, I strongly recommend that you implement it using method 1a in the child theme. Nevertheless, I would like to show you a possible alternative.
Installiere dir dazu das Plugin Code Snippets und erstelle ein neues Snippet mit dem oben genannten Code.
Praktisch ist an dem Plugin übrigens, dass du deine Seite damit nicht „zerstören“ kannst. Das Plugin prüft bei Aktivierung des Codes, ob es einen Fehler verursacht. Falls ja, wird der Code nicht aktiviert.
2. Setze [year] als Jahreszahl ein
Then you just have to insert the shortcode "year" in the square brackets, which reads out the year of the server time or date, into the text instead of the manual year.
Fazit: Die Jahreszahl aktualisiert sich von nun automatisch
So einfach sparst du dir mit vier Zeilen Code ein nerviges, jährliches Ritual – vor allem wenn du mehrere Webseiten pflegst. Ich empfehle dir, es mit Variante 1a umzusetzen. Wenn du noch kein Child-Theme verwendest, sieh dir meinen Blog-Beitrag dazu an. Auch das ist sehr einfach und schnell erledigt.
0 Comments