elementor / wp2static

WordPress static site generator for security, performance and cost benefits
https://wp2static.com
The Unlicense
1.42k stars 267 forks source link

WPML URL detection sample #512

Open leonstafford opened 4 years ago

leonstafford commented 4 years ago

Submitted by @stevygee: https://gist.github.com/stevygee/ed18db68a247c2cd4fb7680d39d41502

consider whether in Advanced Detection add-on or WPML specific add-on if other functionality makes sense to bundle

jeffceriello commented 4 years ago

Hi Leon,

I have an issue with WPML now. Hope you can help.

I've added @stevygee's snippet and with that I managed to get all pages crawled but when I deploy on the S3 bucket I get a Forbidden error on the translated page.

http://m86zur9g.s3-website-eu-west-1.amazonaws.com/en-US/contact-us/

The rest of the website works well. What could it be?

Thanks

jeffceriello commented 4 years ago

Hi Leon, just as an update on this. I've moved to Polylang and it's all working smoothly.

Thanks

leonstafford commented 4 years ago

Great, @jeffceriello - I will still get to optimizing WP2Static for WPML/Polylang (fairly high on todo list), but I think Polylang is the better option anyway. I've chatted with one of the Polylang devs (from France, I believe) and heard good reviews. Cannot say the same (or close) for WPML as a company/software ;)

bkno commented 2 years ago

Deleted my last comment as in the end I was able to get this working with stevygee's gist with a few tweaks. The main change was querying all public custom post types, and an additional param to the wpml_permalink to get translated permalinks.

However, I have found that when retrieving translated permalinks in the crawler, it is impacted by what the language switcher on the admin menu is set to. This can cause some translations not to be fetched. Investigating further..

During the process, I also tried Polylang. This was very smooth as mentioned above, no extra code needed.

bkno commented 2 years ago

I found that disabling WPML > Languages > "Adjust IDs for multilingual functionality" allows WP2Static to crawl all the translations. It fixed the issues I was having with the script above in relation to the language switcher.

In fact.. I don't think any script is needed anymore, at least for my situation where the translations each have different permalinks. The crawler can discover them by itself.