Pull Request: Filter Permalinks for Scheduled Posts
-
Hi there
I’m using the latest version of Polylang (1.7.5) on a client site and noticed some unexpected behaviour.
In the
PLL_Links::post_type_link
andPLL_Links::_get_page_link
methods you filter custom posts links, with the following comment:// /!\ when post_status is not "publish", WP does not use pretty permalinks
This, however, isn’t true. WordPress also uses pretty permalinks for scheduled posts (post_status “future”), that’s why the preview for scheduled posts isn’t working.
Expected URL for scheduled post: https://example.com/fr/my-post-type/example-post-in-french/
Actual URL returned by Polylang: https://example.com/my-post-type/example-post-in-french/Suggested fix:
Change the if clause in
_get_page_link
to something like the following:// /!\ when post_status is not "publish" or "future", WP does not use pretty permalinks return $post->post_status != 'publish' && $post->post_status != 'future' ? $link : $this->links_model->add_language_to_link($link, $this->model->get_post_language($post->ID));
And the one in
get_post_link
to something like:// /!\ when post_status is not "publish" or "future", WP does not use pretty permalinks if ('publish' == $post->post_status || 'future' == $post->post_status && $this->model->is_translated_post_type($post->post_type)) {
- The topic ‘Pull Request: Filter Permalinks for Scheduled Posts’ is closed to new replies.