wp2static icon indicating copy to clipboard operation
wp2static copied to clipboard

WPML URL detection sample

Open leonstafford opened this issue 5 years ago • 5 comments

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

leonstafford avatar Mar 31 '20 21:03 leonstafford

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 avatar May 05 '20 13:05 jeffceriello

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

Thanks

jeffceriello avatar May 06 '20 15:05 jeffceriello

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 ;)

leonstafford avatar May 06 '20 17:05 leonstafford

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 avatar May 09 '22 16:05 bkno

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.

bkno avatar May 10 '22 11:05 bkno