WordPress.org

Ready to get started?Download WordPress

Forums

Query Multiple Taxonomies
[resolved] Query Multiple Taxonomies AND qTranslate (3 posts)

  1. stare
    Member
    Posted 2 years ago #

    I'm strugeling to make this plugin work with the qTranslate plugin!
    Especially with the taxonomy name?

    I addes a custom post type and a taxonomy with qTranslate Tags:

    function post_type_test() {
    register_post_type('test',
    ...
    )
    );

    // Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
    'name' => _x( '[en:]English[de:]German', 'taxonomy general name' ),
    ...
    );

    register_taxonomy('location',array('accommodation'), array(
    'labels' => $labels,
    ...
    ));
    }
    add_action('init', 'post_type_test');

    The Widget always displays: "[en:]English[de:]German" instead of "English" OR "German"!

    Changing the line 154 in the widget.php file to the following doesn't help?
    'title' => __(get_taxonomy( $taxonomy )->label),
    Any help is apreciated!

    This changes I made already to add qTranslate functionality:

    widget.php Line 281 change the following to display the taxonomy values in the correct language:

    'name' => $term->name,
    to
    'name' => __($term->name),

    functins.php add the following to add extra Textboxes to edit the values in the chosen languages:


    /* qTranslate for Custom Taxonomy */
    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');

    http://wordpress.org/extend/plugins/query-multiple-taxonomies/

  2. stare
    Member
    Posted 2 years ago #

    Ok figured it out:

    Change the line 154 in the widget.php file to the following doesn't help?
    'title' => __(get_taxonomy( $taxonomy )->label),

    and use the following tags:

    'name' => _x( '<!--:en-->English<!--:--><!--:de-->German<!--:-->', 'taxonomy general name' ),

  3. icc97
    Member
    Posted 2 years ago #

    Congrats to Qian Qin for writing some easily extensible code!

    Here's a relatively simple way of adding translations your own custom taxonomies. Assuming you've registered a taxonomy, 'my_cat', add these two lines into qtranslate_hooks.php, near the end of the file around line 244 (search for '// Hooks (Actions)' in the file).

    // Custom Taxonomies
    add_action('my_cat_add_form',		'qtrans_modifyTermFormFor');
    add_action('my_cat_edit_form',		'qtrans_modifyTermFormFor');

    That will add the translation fields in the admin pages for your custom category.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic