Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 -
- 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 -

Supporter timezone: Asia/Dhaka (GMT+06:00)

This topic contains 5 replies, has 3 voices.

Last updated by Prosenjit Barman 1 year, 5 months ago.

Assisted by: Prosenjit Barman.

Author Posts
December 19, 2023 at 3:54 pm #15094623

capucineG

I have an archive for a CPT that doesn't show the translated page if there's no post. It works fine of there's a post, but as soon as I make it a draft, the page dissapears from translations. I saw in a similar forum question that if no posts, there no archive, but in my case, there is content on the archive page, this content is translated correctly, please help.

December 19, 2023 at 5:09 pm #15095481

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hi,

thanks for contacting us.

What do you mean with "there's content on the archive page"? If the page is just a template, not a *real* page, even if there is something like the description it's correct not seeing it.

Unless you have a page called archive or something like that this is the expected behavior

December 19, 2023 at 6:30 pm #15095893

capucineG

An archive page can have other content than just posts, and the other content is important here. The CPT is jobs, the archive page is the send us your resume / here are job openings, so if there's no openings, the form still needs to be accessible (on the archive).

December 20, 2023 at 2:30 pm #15103547

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
I hope you're doing well.

I understand your requirements. If the Archive page that you're referring to is a template and you've translated the template properly from WPML > Translation Management, then you should be able to access the Archive template in the frontend. But, to assist you better, could you kindly share how you have created the CPT and rendering the archive in the frontend? I'll check based on that and try my best to assist you in this matter.

Looking forward to your response.

Best regards,
Prosenjit

December 20, 2023 at 3:08 pm #15103921

capucineG

Thanks Prosenjit!

So, first of all, it's an Elementor website using templates as archives. The CPT is managed with CPT UI, and it is set to translatable (in the post types in WPML) I checked if there were any strings not translated related to that archive and couldn't find any (with string translations).

I have translated the archive template, and I made a "test" post, which I translated too. Everything works fine when there's a post, but if I delete the post (no posts to show) then the language switcher dissapears (the 'connexion' between the french and english archives is lost), but the archive remains available and I can get to it from the english menu without any problem, the problem is when switching from english to french from the lang selector on that page only, if I click it while no job posts are published (no jobs offerings at the moment), it brings me to home page instead of seeing the translated archive.

Right now, I'm "cheating" the system to make it work, I made a post with my text 'no jobs available at the moment' and I'm serving that as alternate template, that way I always have a post. But I don't want this to stay like that, it's not the way it should be and I need it to be fixed.

December 21, 2023 at 9:37 am #15108165

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There,
Thank you for nicely clarifying everything!

Let me inform you that in WordPress, there is a general behavior where an archive page (be it for categories, tags, custom post types, or any other taxonomy) is typically only displayed if there are posts associated with it. This means that if an archive (like a category archive) doesn't contain any posts, WordPress usually doesn't display the archive template and may instead show a 404 Not Found page or a message indicating that no posts are available.

How a post-type archive will be displayed in the frontend is entirely handled in the core of WordPress. WPML's role is limited in this aspect; it can provide translations for the post type and its archive template, but it cannot alter the fundamental way WordPress handles the presentation of post-type archives. Essentially, WPML adds language support but doesn't change the underlying behavior of WordPress regarding archive display. I hope you can understand.

To make an archive page appear in other languages even when there are no posts, additional custom coding is required which falls beyond the scope of our support. But, I will try my best to help in this matter by providing suggestions and guidance.

You can check this Stackoverflow thread that is close to the issue you're having: https://stackoverflow.com/questions/43344348/wordpress-show-archive-even-though-there-are-no-posts

You can also make further customization by using the WPML Hooks. Please check this Hook Guide: https://wpml.org/wpml-hook/

The "wpml_current_language", "wpml_object_id", "icl_ls_languages" might be helpful in this matter.

You can also hire a certified contractor from here: https://wpml.org/contractors/

They are specialized in customizing WPML and I hope they can help you in this matter.

I hope you can understand. If there is anything else I can help you with, please let me know. I will be happy to help.

Best regards,
Prosenjit

The topic ‘[Closed] CPT archive not showing if no posts’ is closed to new replies.