我有一个由 Wordpress 中的模板制作的网站,我安装了一个翻译插件(qtranslate)。
http://madebysylvie.be/collection
在我的“相册”页面中,当我以默认语言(英语)对项目进行排序时,一切正常,但是如果我更改为另一种翻译(例如法语),则类别名称会更改并且标记的项目不会出现了。
这是执行该函数的 PHP 代码,
<ul class="filter_portfolio">
<?php
// Get the taxonomy
$terms = get_terms('filter', $args);
// set a count to the amount of categories in our taxonomy
$count = count($terms);
// set a count value to 0
$i=0;
// test if the count has any categories
if ($count > 0) {
// break each of the categories into individual elements
foreach ($terms as $term) {
// increase the count by 1
$i++;
// rewrite the output for each category
$term_list .= '<li class="segment-'.$i.'"><a href="javascript:void(0)" data-value="' . $term->slug . '">' . $term->name . '</a></li>';
// if count is equal to i then output blank
if ($count != $i)
{
$term_list .= '';
}
else
{
$term_list .= '';
}
}
// print out each of the categories in our new format
echo $term_list;
}
?>
</ul>
我想更改此代码块以识别翻译版本中的标签。我知道触发器是 ("data-value") 参数。
下面的代码让我翻译默认语言的分类法,
function qtranslate_edit_taxonomies(){
$args=array(
'public' => true ,
'_builtin' => false
);
$output = 'object'; // or objects
$operator = 'and'; // 'and' or 'or'
$taxonomies = get_taxonomies($args,$output,$operator);
if ($taxonomies) {
foreach ($taxonomies as $taxonomy ) {
add_action( $taxonomy->name.'_add_form', 'qtrans_modifyTermFormFor');
add_action( $taxonomy->name.'_edit_form', 'qtrans_modifyTermFormFor');
}
}
}
add_action('admin_init', 'qtranslate_edit_taxonomies');
?>
非常感谢您的帮助!