Background of the issue:
Ich versuche, einen Sprachumschalter-Block in einer Blockvorlage auf Englisch einzufügen. Die Hauptsprache ist Deutsch. Ich verwende die Vorlage: twentytwentyfour.
Symptoms:
Wenn ich den Sprachumschalter-Block einfüge und auf die Schaltfläche Speichern/Aktualisieren klicke, erhalte ich die Fehlermeldung 'Speichern fehlgeschlagen.'
Questions:
Warum erhalte ich die Fehlermeldung 'Speichern fehlgeschlagen', wenn ich den Sprachumschalter-Block einfüge?
Gibt es bekannte Probleme mit dem WPML-Plugin und dem twentytwentyfour-Theme?
I noticed also, that this problem is not related to the language switch, if I change something on the english template page, i get a "Invalid JSON response" error.
In the browser error console i get the message "{"code":"rest_post_invalid_id","message":"Invalid post ID.","data":{"status":404}}".
So, there is something wrong with the WPML settings and WordPress block themes.
I tested this problem also in a clean, empty WordPress installation, only WPML activated.
The same happens, if i try to save the edited EN template:
JavaScript/Rest API error "hidden link"
I think now about this: this REST API URL is using "/en/" because i try to edit the english template. Maybe "hidden link" is simply just not registered in WPML?
I translated the template-part "header" in the WPML menu "Translation Managment" (just copied the markup of DE into the translation window of EN). That doesn't help.
Is there a way to set up the REST API with WPML correctly?
I apologize for the delay in responding. I will take care of this ticket; the reply time will be shorter now.
If you try with the Twenty Twenty Five theme the issue persist?
The Rest Api should work out of the box with WPML. WPML uses it internally for many things.
Can you please copy here the full error that you get in the browser's console when trying to save?
Also, please follow the instructions mentioned on this page: https://wpml.org/documentation/support/debugging-wpml/
Then, try to reproduce the issue and check your installation's **wp-content** folder to see if a file named **"debug.log"** was created (it will only be generated if a server error occurs).
If the file was created, please upload it to a platform like **Google Drive** or **Dropbox** (whichever you usually use) and share the link with me (make sure it is publicly accessible) so I can analyze it.
The error also happens with twentytwentyfive theme. See the attached image, the image explains which steps i took until the error appeared.
The exact error message is:
"hidden link" 404 Not found
If i alter something in the german verson - which works without any error - of the header, the url might me: hidden link -> WITHOUT "/en/"
So, there is maybe a problem with the /en/-URL? Is there some setting in WPML i should make?
I gueass WPML is parsing the template, template-parts, and patterns directories, but fails with a kind of "registering" - and the REST API URL above (with /en/) remains unknown.
Analyzing the header-related coded reveals this:
Content of themes/twentytwentyfive/parts/header.html:
<!-- wp:pattern {"slug":"twentytwentyfive/header"} /-->
(This code loads the pattern "header.php" from patterns directory)
Can you please help me with that? I created a clean installation of WordPress, WPML, and all necessary WPML add-ons.
You can access the WordPress dashboard using the link below: hidden link
Kindly follow the steps below:
- Don't restore your site there.
- Try to replicate the issue with minimal steps.
- Then let me know the steps to see the problem.
Wow, Otto, thanks a lot for the sandbox installation.
You're right, the problem doesn't happens in your sandbox. I compared also the WPML settings, they are equal to my WPML-Settings.
I installed also WPML string translation, as it is on the sandbox installed, no result.
However, there is an issue in the Server-Request-Headers, please see my attached image below.
My response header "link" is the URL WITHOUT EN, but the URL with EN is requested, the sandbox request headers are fine, the request URL and the header link URL are the same.
I am running the installation locally with xampp, Apache and MySQL.
I don't know what to do now. Have you any idea why the request header link differs from the requested URL???
For the moment, i switch to a hybrid theme (means a classiv theme which is using patterns), that is more hassle-free. Perhaps the problem doesn't occur on a remote server, but I want to test and develop locally.
I work now over many years with xampp... using block themes with WPML is for me a very special use case, so I try to stick to xampp. Other tools, other errors. No thank you.
Btw. hybrid themes have some advantages for me. I like the old way to build menus. I can create a custom menu walker with PHP - for block themes you have to build a new Gutenberg block i guess, an this is rather complicated...
So, thanks for your help, so far. I don't have the time to dig into the local environment issue now, perhaps later.
I can not mark the issue as resolved. Since the post is visible to the community, perhaps someone has an idea...