Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Qtranslate, category custom field (custom post type) WordPress

I have a custom post type (pierre). I have enable category for this custom post type. And after i have added some custom field to the custom post type.

I have installed qtranslate, but the translation only work for the title.

How can i enable the traduction for descritpion and other field ?


My code for extra field:

/*Ajouter champs perso ‡ categorie d'un custom post type*/


add_action ( 'pierre_categories_edit_form_fields', 'extra_category_fields');

//add extra fields to category edit form callback function
function extra_category_fields( $tag ) { //check for existing featured ID
$t_id = $tag->term_id;
$cat_meta = get_option( "category_$t_id");
?>

<tr class="form-field">
<th scope="row" valign="top"><label for="cat_soustitre">Source de la description</label></th>
<td>
<input type="text" name="cat_meta[sourcedesc]" id="Cat_meta[sourcedesc]" size="3" style="width:60%;" value="<?php echo $cat_meta['sourcedesc'] ? $cat_meta['sourcedesc'] : ''; ?>">
<span class="description">Source de la description</span>
</td>
</tr>


<tr class="form-field">
<th scope="row" valign="top"><label for="cat_soustitre">Propri&eacute;t&eacute;s</label></th>
<td>
<ul>
<li style="display:inline-block; margin-right:15px; width:140px;">
<input type="text" name="cat_meta[refraction]" id="Cat_meta[refraction]" size="3" style="width:100%;" value="<?php echo $cat_meta['refraction'] ? $cat_meta['refraction'] : ''; ?>">
<br /> <span class="description">Indice de r&eacute;fraction</span>
</li>

<li style="display:inline-block; margin-right:15px; width:140px;">
<input type="text" name="cat_meta[durete]" id="Cat_meta[durete]" size="3" style="width:100%;" value="<?php echo $cat_meta['durete'] ? $cat_meta['durete'] : ''; ?>">
<br /><span class="description">Duret&eacute; (sur 10)</span>
</li>

<li style="display:inline-block; margin-right:15px; width:140px;">
<input type="text" name="cat_meta[densite]" id="Cat_meta[densite]" size="3" style="width:100%;" value="<?php echo $cat_meta['densite'] ? $cat_meta['densite'] : ''; ?>">
<br /><span class="description">Densit&eacute;</span>
</li>

</ul>
</td>
</tr>
<div style="clear:both;"></div>




<?php
}

add_action( 'edited_pierre_categories', 'save_extra_taxonomy_fields');
function save_extra_taxonomy_fields( $term_id ) {
if ( isset( $_POST['cat_meta'] ) ) {
$t_id = $term_id;
$cat_meta = get_option( "category_$t_id");
$cat_keys = array_keys($_POST['cat_meta']);
foreach ($cat_keys as $key){
if (isset($_POST['cat_meta'][$key])){
$cat_meta[$key] = $_POST['cat_meta'][$key];
}
}
//save the option array
update_option( "category_$t_id", $cat_meta );
}
}




Answers (3)

2014-03-13

Sabby Sam answers:

Hi Robin,
Why you should not try WPML plugin ?


Robin Ferrari comments:

Because I already start with qtranslate and I more I'm used to this plugin.


Sabby Sam comments:

Hi Robin,
Can you please pm me details, I cannot judge with the above code.
Thanks

2014-03-13

Arnav Joy answers:

so are extra meta fields are not available ?
how you added new fields ?

2014-03-14

Photoshop answers:

check this , you only can see the extra fields when you edit the category only
http://en.bainternet.info/2011/wordpress-category-extra-fields


Photoshop comments:

Sorry update,
check this , you only can see the extra fields when you edit the category only
[[LINK href="http://en.bainternet.info/2011/wordpress-category-extra-fields"]]http://en.bainternet.info/2011/wordpress-category-extra-fields[[/LINK]]


Photoshop comments:





add_action('category_add_form_fields','extra_category_fields');
then play around


Robin Ferrari comments:

The meta Field is available but not with the function of the plugin qTranslate