get_permalink() returns in wrong format via AJAX


In short, we have a CPT, we display the post on a page and we have a filter that uses AJAX.
The loop on the page and in the AJAX script both use the same template file to actually show the posts.
Permalinks are set to /%postname%/.

The title, text, image and extra info fields is all displayed correctly both on the initial page and the AJAX results.

But the permalink is not the same. We use get_permalink($postid) to get them.
On the initial page load, the permalinks are correct, with the postname.
On the results returned by the AJAX script, the permalinks are like: ?p=100

Any idea what might cause this?

YourManDan 1 week 2023-03-10T10:19:15-05:00 0 Answers 0 views 0

Leave an answer