Last active
December 10, 2017 20:43
-
-
Save samikeijonen/c3c64ec2503749e7d578ca1e0d744706 to your computer and use it in GitHub Desktop.
Translate only terms from taxonomy "contact_area" when filterin "contact" post type posts. Posts are not translates at all because they only have name, email, and phone number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $terms = get_terms( array( | |
| 'taxonomy' => 'contact_area', | |
| 'hide_empty' => false, // Other than default language don't have any posts. | |
| 'orderby' => 'name', | |
| 'lang' => function_exists( 'pll_current_language' ) ? pll_current_language() : '', | |
| ) ); | |
| if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) : | |
| foreach ( $terms as $term ) : | |
| // Always use default language ID because we don't have translations for other languages. | |
| $term_default_lan_id = function_exists( 'pll_get_term' ) ? pll_get_term( $term->term_id, pll_default_language() ) : $term->term_id; | |
| echo '<option value="' . $term_default_lan_id . '"' . selected( $term->slug, 'hallinto', false ) . '>' . $term->name . '</option>'; | |
| endforeach; | |
| endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment