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.

Tagged: 

This topic contains 13 replies, has 2 voices.

Last updated by Raja Mohammed 1 month ago.

Assigned support staff: Raja Mohammed.

Author Posts
August 22, 2019 at 11:04 am #4438539

cedricB-21

I am creating a custom post type including a custom taxonomy in my wordpress plugin this way:

// Taxonomy
add_action( 'init', 'register_help_post_type' );
function register_help_post_type() {
    register_post_type( 'help',
        array(
            'labels' => array(
                'name' => 'Help Posts',
                'menu_name' => 'Help Manager',
                'singular_name' => 'Help post',
                'all_items' => 'All Help Posts'
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'show_in_nav_menus' => true,
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'post-formats', 'revisions' ),
            'hierarchical' => false,
			'has_archive' => 'help',
			'show_in_rest' => true,
            'taxonomies' => array('help-category'),
            'rewrite' => array( 'slug' =>  _x('help', 'URL slug'))
        )
    );
    register_taxonomy( 'help-category', array( 'help' ),
        array(
            'labels' => array(
                'name' => 'Help Categories',
                'menu_name' => 'Help Categories',
                'singular_name' => 'Help Category',
                'all_items' => 'All Categories'
            ),
            'public' => true,
            'hierarchical' => true,
            'show_ui' => true,
            'show_in_rest' => true,
            'rewrite' => array( 'slug' =>  _x('help', 'URL slug'))
        )
    );
}

In the WMPL settings, I am setting the CPT to be translated and I have also translated the taxonomies.

I am also using the plugin WP Better Permalinks (https://wordpress.org/plugins/wp-better-permalinks/) in order to change the way permalinks work in wordpress, this means my URL based on the code above will work in the following way:

domain.com/help/[help-category-terms-slug]/[single-help-post]

The URL structure in the post when saving in different languages work perfectly fine, however when I visit the link it gives me a 404 error.

All permalinks have been flushed several times.

Did you ever experience such issue, am I maybe registering the CPT or Taxonomy incorrectly for WPML? Your help is greatly appreciated.

August 22, 2019 at 11:44 am #4438907

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi there,

Seems like I have lost connection with you during the chat, I have converted the chat to a forum ticket for continued assistance.

Can you please clarify whether the plugin uses the same format as WP permalinks like %postname% and can it be altered from settings > permalinks?

Kind regards
Raja

August 22, 2019 at 11:46 am #4438909

cedricB-21

What the plugin does is adds rules to .htaccess file since the better permalinks wasnt written by me i thought you had osme experience from previous customers

August 22, 2019 at 1:04 pm #4439557

cedricB-21

Any update?

August 22, 2019 at 1:42 pm #4439797

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

This is a third party plugin we are not very much aware of the internal workings,
The plugin authors can help in this case.

There are a few other options you can try. https://wordpress.org/plugins/permalinks-customizer/

However, if you can isolate the issue on the fresh installation I would be able to check this further with Wp Better Permalinks plugins. Install Better permalinks to the test site and try to reproduce the issue

One-Click Login:hidden link

Let me know once done.

Regards
Raja

August 22, 2019 at 2:07 pm #4440071

cedricB-21

Hi Raja,

I installed Better Permalinks plugin and also my plugin with the custom post type etc.

I configured the WPML to have English as default language and Italian language.

I set the custom post type and Taxonomy to be translated too - Also enabling string translation plugin.

I created Categories in the taxonomies for both English and Italian in the Help Manager Custom Post Type menu item

I created categories and post within my custom post types which in the menu you will find under the item 'Help Manager'

WP Better Permalinks is working perfectly fine and creating the correct URL structure if you look into the posts in the help manager

If you visit the English version it works perfectly fine, however, if you try to access the Italian Version it gives a 404 page.

English URL: hidden link

Italian URL: hidden link

August 22, 2019 at 2:08 pm #4440073

cedricB-21

Please confirm you understood my message above and you will be debugging my issue. Feel free to change anything in my plugin. Please let me know what you have done then so I can easily replicate

August 22, 2019 at 2:12 pm #4440129

cedricB-21

If you can help me achieve the same result I have done in the demo installation you gave me using the plugin: https://wordpress.org/plugins/permalinks-customizer/

Please let me know how 🙂 Thanks so much for your support

August 22, 2019 at 8:33 pm #4442825

cedricB-21

I have spoken to the developer of WP Better Permalinks and we did try to debug the issue. It doesn't seem that the issue is coming from the Permalinks plugin.

We are Using

generate_rewrite_rules

filter, we added the following redirection:

[it/assistenza/parent-category-it/child-category-it/test-post-it/?$] => index.php?help=test-post-it

In CMS there is a post with test-post-it post name (post type is help), in Italian. Unfortunately, after entering this address we have error 404.

August 23, 2019 at 9:34 am #4445667

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

This seems like a compatibility issue since it is reproduced on a new sandbox site, I will escalate the issue to the compatibility team for further help.

Please note this might take some while. Unfortunately, I don't have any further suggestion for your case.

I would request your patience in this regard

Kind regards
Raja

August 23, 2019 at 10:23 am #4445907

cedricB-21

Hi Raja,

I am tight with a deadline for this project and need to know ASAP is this will be possible to do or no. Do you at least have an estimated time when I can get an answer if it can be fixed or no from your end?

If not, I would have then need to ask for a refund as WPML is not serving my needs!

Thanks

August 23, 2019 at 11:56 am #4446583

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

This is a compatibility issue in most cases our developers will be able to give you a possible workaround and we try our best to contact the plugin author to make the plugin compatible with WPML.

We do our best to make WPML compatible with everything else in the WordPress world. However, much of it is not in our hands.

Whether it is possible or not is always a "Yes and No" which depends on the compatibility of the code with WPML. In most cases it is possible.

Since the issue has been escalated for the attention of the compatibility team,

Your patience in this regard is highly appreciated.

Our support policy https://wpml.org/purchase/support-policy/

August 28, 2019 at 6:43 am #4471433

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Our developers from compatibility team have suggested a workaround, I have tested the code t on the sandbox site, I can confirm it works as expected.

Please open the file wp-content/plugins/wp-better-permalinks/functions/posttypes/rewrites.php remove the lines 35 - 38 and replace it with the code below.

 foreach ($this->core->posttypes->options['posts'] as $rewrite)
        foreach ($this->core->posttypes->options['posts'] as $post_id => $rewrite) {
          $lang = apply_filters('wpml_element_language_code', null, array('element_id' => $post_id, 'element_type' => get_post_type($post_id)));
          $home_url = apply_filters('wpml_permalink', home_url(), $lang);
          $path = substr(trailingslashit(parse_url($home_url, PHP_URL_PATH)),1);
          $rewrite['regex'] = preg_replace("~^$path~", '', $rewrite['regex'], 1);
           $list[$rewrite['regex'] . '/?$'] = $rewrite['path'];
        }
 
         $wp_rewrite->rules = $list + $wp_rewrite->rules;
         return $wp_rewrite->rules; 

After modifying the code we should go to Settings > WP Better Permalinks and save.

Let me know if you need any assistance.

Kind regards
Raja

September 12, 2019 at 7:10 am #4558733

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The plugin author has identified an issue with the taxonomies, Our compatibility team has suggested a fix for it as well https://wordpress.org/support/topic/wpml-compatibility-177/#post-11922339

The plugin author has been invited to our go global program for complete compatibility with WPML