WPML

2017-06-07 3 views
9

में एक कस्टम पोस्ट प्रकार स्लग का अनुवाद करने में असमर्थ मैंने इस मुद्दे को WPML फ़ोरम पर उठाया है, लेकिन उम्मीद है कि यहां कोई व्यक्ति सहायता कर पाएगा।WPML

मैं जब URL पर नेविगेट अनुवाद यूआरएल http://brigade-electronics.com/nl/producten/backeye360/

इसके बजाय होना चाहिए एक कस्टम पोस्ट प्रकार

अंग्रेजी यूआरएल http://brigade-electronics.com/nl/products/backeye360/

है के लिए स्लग मैं 404 त्रुटि मिली अनुवाद करने के लिए कोशिश कर रहा हूँ अनुवाद स्लग विकल्प सक्षम करने के बाद

समस्या को डुप्लिकेट करने के चरण:

  • WPML पर क्लिक करें -> अनुवाद विकल्प
  • अनुवाद कस्टम पोस्ट स्लग (WPML स्ट्रिंग अनुवाद के माध्यम से) सक्षम करें।
  • कस्टम पदों सेटिंग्स (एक ही पृष्ठ पर) क्लिक करें प्रत्येक भाषा
  • बचाने हिट
  • नेविगेट सामने अंत करने के लिए के लिए चेकबॉक्स
  • जोड़ा गया अनुवाद स्लग अनुवाद और उत्पादों खंड पर एक 404 त्रुटि को देखने के केवल।

डेटाबेस को साफ़ करने के लिए मैंने समस्या निवारण पृष्ठ में सभी विकल्प चलाए हैं।

यह केवल उत्पाद अनुभाग के कुछ पृष्ठों पर लागू होता प्रतीत होता है। इसका अजीब हिस्सा साइट का कनाडाई अनुभाग है, क्योंकि 'उत्पाद' शब्द अंग्रेजी में है, इसलिए URL अनुवादित स्लग के साथ या उसके बिना समान रहते हैं, हालांकि, मुझे अभी भी इन पृष्ठों पर 404 त्रुटि मिलती है।

यह भी ध्यान देने योग्य है कि अन्य सभी कस्टम पोस्ट प्रकार बिना किसी समस्या के काम करते हैं।

कस्टम पोस्ट प्रकार मानक तरीका

function register_products_post_type() { 

    $labels = array(
     'name' => __('Products', ''), 
     'singular_name' => __('Product', '') 
    ); 

    $args = array(
     'label' => __('Products', ''), 
     'labels' => $labels, 
     'description' => '', 
     'public' => true, 
     'publicly_queryable' => true, 
     'show_ui' => true, 
     'show_in_rest' => false, 
     'rest_base' => '', 
     'has_archive' => false, 
     'show_in_menu' => true, 
     'exclude_from_search' => false, 
     'capability_type' => 'post', 
     'map_meta_cap' => true, 
     'hierarchical' => true, 
     'rewrite' => array('slug' => 'products', 'with_front' => false), 
     'query_var' => true, 
     'menu_position' => 6, 
     'menu_icon' => 'dashicons-cart', 
     'supports' => array('title', 'thumbnail', 'page-attributes') 
    ); 

    register_post_type('products', $args); 

} 
add_action('init', 'register_products_post_type'); 

नीचे जवाब के अनुसार में पंजीकृत किया गया है, इसके बाद के संस्करण कोड

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, // An array that defines the different labels assigned to the custom post type 
     'public' => true, // To show the custom post type on the WordPress dashboard 
     'supports' => array('title', 'thumbnail', 'page-attributes'), 
     'has_archive' => true, //Enables the custom post type archive at 
     'hierarchical' => true, //Enables the custom post type to have a hierarchy 
     'rewrite' => array('slug' => _x('products', 'URL slug')), 
    ); 
    register_post_type('products', $args); 
    } 

में प्रकट होता है स्लग के लिए नए अनुवाद करने के लिए अद्यतन किया गया है 'स्ट्रिंग अनुवाद' अनुभाग, इन तारों को अद्यतन करते समय, मुझे वही 404 त्रुटि मिलती है। अगर मैं इसे अंग्रेजी के रूप में छोड़ देता हूं तो उत्पाद अनुभाग कोई समस्या नहीं है।

धन्यवाद

+0

जहां अनुवाद स्लग $ लेबल = सरणी है ( 'नाम' => __ ('उत्पाद', ''), 'singular_name' => __ ('उत्पाद', '') ); - टेक्स्ट डोमेन गुम है –

+0

इससे अन्य सभी कस्टम पोस्ट प्रकारों में कोई फर्क नहीं पड़ता है, वे सभी एक ही सेट अप हैं, लेकिन यह एक कोशिश करेगा और आपको – terrorfall

+0

हाय @MujeebuRahman एक डोमेन जोड़ने से कोई फर्क नहीं पड़ता – terrorfall

उत्तर

1

इस

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, // An array that defines the different labels assigned to the custom post type 
     'public' => true, // To show the custom post type on the WordPress dashboard 
     'supports' => array('title', 'thumbnail', 'page-attributes'), 
     'has_archive' => true, //Enables the custom post type archive at 
     'hierarchical' => true, //Enables the custom post type to have a hierarchy 
     'rewrite' => array(_x('slug' => 'products'), 'with_front' => false), 
    ); 
    register_post_type('products', $args); 
    } 
+0

इस https://wpml.org/2016/08/how-to-create-and-translate-custom-post-types/ – vel

+0

पढ़ें इससे डर नहीं है, फिर भी स्विच करने पर 404 त्रुटि प्राप्त हो रही है अनुवादित स्लग। – terrorfall

+0

क्या आपने "सुंदर पर्मलिंक्स" को अक्षम और पुनः सक्षम करने का प्रयास किया है? – vel

0

आप फिर से लिखने के नियम प्लावित है का प्रयास करें?

सेटिंग्स> परमालिंक और रीफ्रेश पर जाएं।

नोट: यदि एक प्लगइन के अंदर एक पोस्ट प्रकार दर्ज की, flush_rewrite_rules() (नीचे देखें एक्टिवेशन पर फ्लशिंग पुनर्लेखन) कहते हैं अपना सक्रियण और छोड़ना हुक में।यदि flush_rewrite_rules() उपयोग नहीं किया गया है, तो आपको अपने कस्टम पोस्ट प्रकार सही संरचना दिखाए जाने से पहले सेटिंग्स> पर्मलिंक्स और मैन्युअल रूप से अपने परमालिंक संरचना को रीफ्रेश करना होगा।

स्रोत: https://codex.wordpress.org/Function_Reference/register_post_type