Background of the issue:
I am trying to use url_to_postid() to convert a URL to a post ID. For instance, the following call always returns 0: url_to_postid('hidden link'). This happened recently, before there was no such issue. I tried to delete various WPML caches but this made no difference. Link to a page where the issue can be seen: hidden link
Symptoms:
The API should return the post ID, but instead, I got 0.
Questions:
Why does url_to_postid() return 0 for a valid URL in the secondary language?
How can I resolve the issue of url_to_postid() not returning the correct post ID?
before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.
I came across an old, archived ticket from you from 2023, where you reported a similar issue with this function while using PHP 8.0:
We found the root cause: the URL parameter was in some occasion a SimpleXMLElement instance and not a string. We added a type cast to a string and it works now fine.
Have you checked if this change is still in place?
I think you don't understand our problem. The url_to_postid() API is failing. We have to convert a URL to a post ID and not vice versa. This was working fine in the past and suddenly stopped working.