Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using WPML plugin to translate my site. I have a custom post type called "vinos" and I use this args:

$args = array( 
            'labels' => $labels,
            'hierarchical' => false,
            'supports' => array('title', 'thumbnail'),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'menu_position' => 6,
            'show_in_nav_menus' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => false,
            'has_archive' => 'nuestros-vinos/catalogo',
            'query_var' => true,
            'can_export' => true,
            'capability_type' => 'post',
            'rewrite' => array('slug' => 'nuestros-vinos/catalogo/marcas/%marcas%')
    );
    register_post_type('vinos', $args);

The problem is that I can't translate my string "nuestros-vinos/catalogo/marcas" to english and for that reason my urls are:

www.domain.com/nuestros-vinos/catalogo/ ---------> show all my list of wines in spanish www.domain.com/en/nuestros-vinos/catalogo/ ------> show all my list of wines in english

but I would like that in english version, the url was:

www.domain.com/en/our-wines/catalog/

I'm trying to use rewrite rules:

add_filter('generate_rewrite_rules', 'customposttype_rewrites');
function customposttype_rewrites($wp_rewrite) {
    $newrules = array();
    $newrules['en/our-wines/catalog/?$'] = 'en/index.php?post_type=vinos';
    $wp_rewrite->rules = $newrules + $wp_rewrite->rules;
}

But it doesn't work, always page not found.

How can I do it?

Thanks.

share|improve this question
    
possible duplicate of Internationalize / translate custom post types & taxonomies –  s_ha_dum Jun 14 '13 at 15:27
    
It doesn't work. –  Mike Jun 14 '13 at 15:29
    
Have you tried that with 'has_archive' => true instead of naming the archive explictly? –  s_ha_dum Jun 14 '13 at 15:35
    
Have you tried the relative new feature of WPML 2.8.2 that now lets you translate custom post type slugs? This feature is still in beta, but it might work... –  Piet Jun 24 '13 at 5:23

2 Answers 2

Try the solution mentioned here: http://wpengineer.com/2044/custom-post-type-and-permalink/ which basically entails re-saving your permalink settings once again.

Example: set permalinks to default structure, save. Switch to your desired permalink structure, save again and then check again if your custom post permalink issue persists.

I have had 404 issues in the past with custom post permalinks and the solution mentioned above worked for me.

Edit: Also, hopefully you don't have enabled any caching plugins while you are coding, just forgot to mention this.

share|improve this answer

this will not work:

'en/index.php?post_type=vinos'

there is no en/index.php, it has to be:

'index.php?post_type=vinos'

if you need to detect en in the path, add a query var, then set that query var in your rewrite:

function wpa_query_vars( $qvars ) {
    $qvars[] = 'wpa_lang';
    return $qvars;
}
add_filter( 'query_vars', 'wpa_query_vars' );

then in your rewrite rule:

$newrules['en/our-wines/catalog/?$'] = 'index.php?post_type=vinos&wpa_lang=en';
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.