{"id":2402,"date":"2015-05-06T16:00:51","date_gmt":"2015-05-06T16:00:51","guid":{"rendered":"http:\/\/musilda.cz\/?p=2402"},"modified":"2015-05-06T16:00:51","modified_gmt":"2015-05-06T16:00:51","slug":"jak-u-wpml-zmenit-ve-vyberu-jazyka-nazev-na-kod","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-u-wpml-zmenit-ve-vyberu-jazyka-nazev-na-kod\/","title":{"rendered":"Jak u WPML zm\u011bnit ve v\u00fdb\u011bru jazyka n\u00e1zev na k\u00f3d"},"content":{"rendered":"
Dne\u0161n\u00ed snippet bude pom\u011brn\u011b jednoduch\u00fd, jde o zm\u011bnu zobrazen\u00ed jazyka u „language selectoru“ u WPML.<\/p>\n
V z\u00e1kladu m\u00e1te mo\u017enost si navolit, zda bude selektor zobrazovat jm\u00e9no jazyka, vlaje\u010dku, nebo oboje. Pokud v\u0161ak pot\u0159ebujete zobrazit jen EN, nebo CS, budete si muset vytvo\u0159it vlastn\u00ed funkci.<\/p>\n
Proto\u017ee m\u00e1 WPML ke ka\u017ed\u00e9mu jazyku pole s hodnotami, vyu\u017eijeme ji\u017e ulo\u017een\u00fd k\u00f3d pro jazyk.<\/p>\n
Do functions.php vlo\u017e\u00edme funkci:<\/p>\n
\nfunction wpml_custom_selector(){\n $languages = icl_get_languages('skip_missing=0&orderby=code');\n $langs = '';\n if(!empty($languages)){\n foreach($languages as $l){\n if($l['active']){ $active = 'active-lang'; }else{ $active = ''; }\n $langs .= ''.$l['language_code'].'<\/a>';\n }\n echo ''.$langs.'<\/div>';\n }\n}\n<\/pre>\nTam kde chcete zobrazit selektor pak jen pou\u017eijete:<\/p>\n
wpml_custom_selector();<\/pre>\nA to je v\u0161e, dne\u0161n\u00ed snippet m\u00e1me za sebou.<\/p>\n","protected":false},"excerpt":{"rendered":"
Dne\u0161n\u00ed snippet bude pom\u011brn\u011b jednoduch\u00fd, jde o zm\u011bnu zobrazen\u00ed jazyka u „language selectoru“ u WPML. V z\u00e1kladu m\u00e1te mo\u017enost si navolit, zda bude selektor zobrazovat jm\u00e9no jazyka, vlaje\u010dku, nebo oboje. Pokud v\u0161ak pot\u0159ebujete zobrazit jen EN, nebo CS, budete si muset vytvo\u0159it vlastn\u00ed funkci. Proto\u017ee m\u00e1 WPML ke ka\u017ed\u00e9mu jazyku pole s hodnotami, vyu\u017eijeme ji\u017e<\/p>\n","protected":false},"author":1,"featured_media":1484,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[550],"class_list":["post-2402","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippety","tag-wpml"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2402"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=2402"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2402\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/1484"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}