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.

This topic contains 12 replies, has 12 voices.

Last updated by Bernd 9 years, 7 months ago.

Author Posts
November 20, 2009 at 12:01 pm #14054


I found that WPML was breaking error 404 functionality when browsing in the site's non-default language, so here's my fix:
1. Edit


2. Replace the function



    function _allow_calling_template_file_directly(){
            global $wp_query, $wpdb;
            $parts = parse_url(get_bloginfo('home'));
            $req = str_replace($parts['path'], '', $_SERVER['REQUEST_URI']);
            if(file_exists(ABSPATH . $req) && !is_dir(ABSPATH . $req)){
				$wp_query->is_404 = false;
                header('HTTP/1.1 200 OK');
                include ABSPATH . $req;

Hope that helps someone.

November 20, 2009 at 1:01 pm #14056


The recent bugfix version of WPML includes a fix for this. Have you tried it?

November 20, 2009 at 1:58 pm #14057


Thanks Amir, I hadn't seen the new version.

March 5, 2010 at 10:08 pm #14058

Wolf-Dieter Grabner

I have the same problem with 1.7.1
Native language works fine but for the translations, 404 doesn't work.

June 19, 2010 at 5:42 pm #14059


So it should work with WP 3? Maybe it's a problem with the theme. But I'd like to ask just for being sure.

June 29, 2010 at 7:54 pm #14060


I think I have a related problem. Running WPML 1.7.9 on wp 2.8.6
Default language English, one additional language (Dutch)
Since the last upgrade every page shows 404 - not found. Except for the posts-page.
To do some basic checking, I've added a error_log message on line 3276 of siteress.class.php, it appears it wp_query cannot determine the type of page so $wp_query->is_404 is set to true.
Does anybody have suggestions? The site is broken now 🙁

July 25, 2010 at 3:07 pm #14061


I also have dennislutz's problem WPML 1.8.0 and WP 3.0
I've found that if I add &lang=en at the end of of original post url, the translation works fine but this is not done automatically.
any ideas?

September 9, 2010 at 1:21 am #14062


Same problem with WPML on WP 3.0.1
Does anyone knows the fix for this?

September 23, 2010 at 8:21 am #14063


Thanks for the help, it seems like they tried to fix it but that version wasn't working. I replaced it with your code and it worked perfectly! Thanks.

October 8, 2010 at 4:58 am #14064


Same problem here with WPML 1.8.3 on WP 3.0.1
Tried Matt's solution and that works brilliant!

November 25, 2010 at 9:20 pm #14065


+1 for Matt's solution. I have the same problem with WPML Version 2.0.0 on WP 3.0.1 with a very slightly modified child theme of twentyten. Any bad URL handled by the translation system gives a 404 error page with a sidebar and it should not. E.g. -> no sidebar, but -> gives a sidebar.

January 9, 2011 at 5:05 pm #14066


Thanks Matt

June 11, 2012 at 9:37 am #62582


Be careful, with this fix you can easily access sensitive information from the site:
E.g. hidden link will return the .htaccess file.

Update: This issue exists in the current unpatched WPML version, too. If you are using permalinks with the language directories option enabled, you can access the .htaccess file.

The topic ‘[Closed] WPML 404 Fix’ is closed to new replies.