{"id":923,"date":"2013-01-08T16:29:35","date_gmt":"2013-01-08T08:29:35","guid":{"rendered":"http:\/\/www.computersolutions.cn\/blog\/?p=923"},"modified":"2013-01-08T16:30:52","modified_gmt":"2013-01-08T08:30:52","slug":"custom-taxonomies-in-wordpress-and-qtranslate-translation-problem-resolution","status":"publish","type":"post","link":"https:\/\/www.computersolutions.cn\/blog\/2013\/01\/custom-taxonomies-in-wordpress-and-qtranslate-translation-problem-resolution\/","title":{"rendered":"Custom Taxonomies in WordPress and QTranslate translation (problem \/ resolution)"},"content":{"rendered":"<p>WordPress has a nice feature called Custom Post types.<\/p>\n<p>(An overview for those that code for WordPress is here &#8211;\u00a0<a href=\"http:\/\/wp.tutsplus.com\/tutorials\/plugins\/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes\/\">http:\/\/wp.tutsplus.com\/tutorials\/plugins\/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes\/<\/a> )<\/p>\n<p>We typically use the Custom Post Types UI plugin (\u00a0<a href=\"http:\/\/wordpress.org\/extend\/plugins\/custom-post-type-ui\/\">http:\/\/wordpress.org\/extend\/plugins\/custom-post-type-ui\/<\/a> ) \u00a0to create, rather than write code. \u00a0The end result is the same though.<\/p>\n<p>&nbsp;<\/p>\n<p>This allows us to create specifically enumerated sets of content relatively easily.<\/p>\n<p>eg &#8211; if you were doing a Site for a Client, you may need a Portfolio section for their web.<\/p>\n<p>With custom post types, you can setup a Portfolio post type, and add various taxonomies (meta data to group or organize these posts by later)<\/p>\n<p>eg \u00a0Category<\/p>\n<p>&nbsp;<\/p>\n<p>Eg if it was for a web design firm, you might add values into the \u00a0Category taxonomy like<\/p>\n<p>Flash<\/p>\n<p>HTML5<\/p>\n<p>CMS<\/p>\n<p>&nbsp;<\/p>\n<p>Then choose those categories when you add a new Portfolio post so that you can later filter by any of those fields.<\/p>\n<p>So far so good.<\/p>\n<p>&nbsp;<\/p>\n<p>We also use another Plugin called QTranslate (\u00a0<a href=\"http:\/\/www.qianqin.de\/qtranslate\/\">http:\/\/www.qianqin.de\/qtranslate\/<\/a> )<\/p>\n<p>QTranslate allows us to add multiple translations for a post, or taxonomy in the WordPress UI.<\/p>\n<p>Its pretty nifty, and a good tool for those that do multilingual wordpress sites.<\/p>\n<p>&nbsp;<\/p>\n<p>QTranslate seems to be a little funky about how it works with Custom Post Types though &#8211; essentially its a little hit and miss whether it actually populates the backend with translation options.<\/p>\n<p>After a bit of googling I found a nice solution to force it to parse taxonomies.<\/p>\n<p>Add this into your Template functions.php at the end of the file, and QTranslate will work properly.<\/p>\n<p><code><\/p>\n<p>function qtranslate_edit_taxonomies(){<br \/>\n   $args=array(<br \/>\n      'public' => true ,<br \/>\n      '_builtin' => false<br \/>\n   );<br \/>\n   $output = 'object'; \/\/ or objects<br \/>\n   $operator = 'and'; \/\/ 'and' or 'or'<\/p>\n<p>   $taxonomies = get_taxonomies($args,$output,$operator);<\/p>\n<p>   if  ($taxonomies) {<br \/>\n     foreach ($taxonomies  as $taxonomy ) {<br \/>\n         add_action( $taxonomy->name.'_add_form', 'qtrans_modifyTermFormFor');<br \/>\n         add_action( $taxonomy->name.'_edit_form', 'qtrans_modifyTermFormFor');<br \/>\n     }<br \/>\n   }<br \/>\n}<br \/>\nadd_action('admin_init', 'qtranslate_edit_taxonomies');<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress has a nice feature called Custom Post types. (An overview for those that code for WordPress is here &#8211;\u00a0http:\/\/wp.tutsplus.com\/tutorials\/plugins\/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes\/ ) We typically use the Custom Post Types UI plugin (\u00a0http:\/\/wordpress.org\/extend\/plugins\/custom-post-type-ui\/ ) \u00a0to create, rather than write code. \u00a0The end result is the same though. &nbsp; This allows us to create specifically enumerated sets of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[436,434,435,120],"class_list":["post-923","post","type-post","status-publish","format-standard","hentry","category-useful-info","tag-custom-post-ui","tag-qtranslate","tag-taxonomy","tag-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/comments?post=923"}],"version-history":[{"count":2,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/923\/revisions"}],"predecessor-version":[{"id":925,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/923\/revisions\/925"}],"wp:attachment":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/media?parent=923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/categories?post=923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/tags?post=923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}