[Closed] Custom post slug of Comic Easel. Part 2

Home Support English Support [Closed] Custom post slug of Comic Easel. Part 2

This topic contains 7 replies, has 2 voices, and was last updated by  Adriano 1 year, 4 months ago. The support staff assigned to this topic is Adriano.

Author Posts
Author Posts
June 28, 2013 at 12:19 pm #139814

José Luis

This is a continuation of http://wpml.org/forums/topic/translate-the-custom-post-slug-of-comic-easel/

Your developer contacted me with some code to add to functions.php:

===========================================================
it turns out that the problem was with the custom post delcaration.
The correct way of doing it

add_action( 'init', 'register_cpt_comic' );

function register_cpt_comic() {

$labels = array(
'name' => _x( 'Comics', 'comic' ),
'singular_name' => _x( 'Comic', 'comic' ),
'add_new' => _x( 'Add New', 'comic' ),
'add_new_item' => _x( 'Add New Comic', 'comic' ),
'edit_item' => _x( 'Edit Comic', 'comic' ),
'new_item' => _x( 'New Comic', 'comic' ),
'view_item' => _x( 'View Comic', 'comic' ),
'search_items' => _x( 'Search Comics', 'comic' ),
'not_found' => _x( 'No comics found', 'comic' ),
'not_found_in_trash' => _x( 'No comics found in Trash', 'comic' ),
'parent_item_colon' => _x( 'Parent Comic:', 'comic' ),
'menu_name' => _x( 'Comics', 'comic' ),
);

$args = array(
'labels' => $labels,
'hierarchical' => true,

'supports' => array( 'title', 'editor' ),

'public' => true,
'show_ui' => true,
'show_in_menu' => true,

'rewrite' => array('slug' => _x('comic', 'URL slug', 'comic')),

'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,

'capability_type' => 'post'
);
register_post_type( 'comic', $args );
}

Note it should be

'rewrite' => array('slug' => _x('comic', 'URL slug', 'comic')),

andNOT

rewrite => true
===========================================================

Using this fix the form entries under "WPML > Translation Options > Custom posts" doesn't dissapear. It has improved but still doesn't work as expected:

1) When using the default custom post type slug ("comic") and disabling wpml slug translations, all languages appear together under http://lang1.andamira.net/comic/, and the translation links point to the home of each language. And from the custom post page, all the translations point to lang1.andamira.net/comic/comic1**/)

2) when using the default custom post type, and enabling wpml slug translations, all works well!

3) when using a custom post type different from the default one, this line in the previous code, needs to be changed in order to match the custom name (comic_en in this case):

'rewrite' => array('slug' => _x('comic', 'URL slug', 'comic')),

'rewrite' => array('slug' => _x('comic_en', 'URL slug', 'comic')),

then it all seems to work well. (after updating translations, permalinks, and so on)

I can live with this fix by now, but I want to know if this problem comes from the wpml plugin or from the comic easel one? Should I contact the comic easel plugin author so that he can fix his custom post type declararation? The idea is not to have to resort to tricks like this.

thank you for everything

June 28, 2013 at 4:03 pm #139904

José Luis

It turns out that I can't live with this fix, because it doesn't work at all on the site I'm building. Here I have 2 diferent domains (not subdomains). One for english and another one for spanish. And the custom slug management is a mess. They are all mixed up:

I'm using the same custom slug I used in the test site, for clarity purposes.

- spanish.domain/comic_es (works!)
- spanish.domain/comic_en (works! and wpml link points
here when I'm on the english.domain, it shouldn't)
- english.domain/comic_es/ (doesn't work, but the wpml link points here when I'm on the spanish.domain. it shouldn't)
english.domain/comic_en (works!)

I can give you access if you desire.

June 28, 2013 at 4:42 pm #139918

José Luis

Please disregard my last message. To be absolute sure I deleted all the database and recreated the site from the start. And now it seemingly works.

In anycase I wanto to know if the bug is on Comic Easel's side, to notify them.

July 1, 2013 at 12:50 pm #140442

Adriano
Forum moderator

Dear José Luis,

Who contacted you to send these codes?

July 1, 2013 at 2:40 pm #140503

José Luis

Hello Adriano,

apparently the lead-developer made it, Andreas Neuber sent it to me on june 24th.

July 1, 2013 at 4:42 pm #140540

Adriano
Forum moderator

Dear José Luis,

I'm in contact with him to understand this issue properly. Thank you for your understanding.

July 1, 2013 at 7:07 pm #140570

José Luis

thank you very much guys!

July 2, 2013 at 4:27 pm #140972

Adriano
Forum moderator

Dear José Luis,

Is this custom post type declared in the Comic Easel or any other plugin is creating this one? If it is called in the Comic Easel, the best thing to do is contact the author of it showing these two topics:

http://wpml.org/forums/topic/custom-post-slug-of-comic-easel-part-2/
http://wpml.org/forums/topic/translate-the-custom-post-slug-of-comic-easel/

The topic ‘[Closed] Custom post slug of Comic Easel. Part 2’ is closed to new replies.