If you want to translate one custom post type slug in WPML? If registering a post type inside of a plugin, call flush_rewrite_rules() in your activation and deactivation hook (see Flushing Rewrite on Activation below). If flush_rewrite_rules() is not used, then you will have to manually go to Settings > Permalinks and refresh your permalink structure before your custom post type will show the correct structure.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | add_action( 'init', 'create_post_type'); function create_post_type() { $labels = array( 'name' => _x( 'Products', 'general name of the post type' ), 'singular_name' => _x( 'Products', 'name for one object of this post type' ), ); $args = array( 'labels' => $labels, 'public' => true, 'supports' => array( 'title', 'thumbnail', 'page-attributes' ), 'has_archive' => true, 'hierarchical' => true, 'rewrite' => array( _x('slug' => 'products'), 'with_front' => false ), ); register_post_type( 'products', $args ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.