• Resolved almerion

    (@almerion)


    Hello, when i create a new tag for my pages or update one, i need to assign a language to this tag. Is there a hook or some way i could be able to not select any language ?

Viewing 1 replies (of 1 total)
  • Thread Starter almerion

    (@almerion)

    nevermind, i found out how to do that, if someone needs it :

    <?php
    add_action('pll_save_term', 'set_creation_of_terms_withou_lang', 10, 3);
    add_filter('get_terms_args', 'remove_lang_inaccessibility', 10, 3);
    
    // creating tags withour lang
    function set_creation_of_terms_without_lang($term_id, $tt_id, $taxonomy) {
        if ($tt_id === "post_tag")
            pll_set_term_language($term_id, null);
    }
    
    // accessing tags that doesn't have lang
    function remove_lang_inaccessibility($args, $taxonomies) {
        if ( in_array( 'post_tag', $taxonomies ) ) {
    
            // Remove any language restrictions by setting "lang" to empty
            $args['lang'] = '';
        }
        return $args;
    }
Viewing 1 replies (of 1 total)

The topic ‘hook tag creation’ is closed to new replies.