Modifying a function
-
This code let me switch the description from italian to german, I’d like to have as output not only the custom meta field content, but at the beginning of the description you should read the category (name of the destination) and the taxonomy (typology of accomodation); these terms too should be translated, in particular the taxonomy term. At the moment 2 different shortcodes and 2 different custom fields do this job (and throw css the category name and the taxonomy term are in a different colour and are bold), but I have to fill to many fields each time I insert a new apartment. Here is the code to modify
//SHORTCODE DESCRIZIONE IN TEDESCO add_shortcode('description', 'translate_desc'); function translate_desc() { global $post; $german = get_post_meta( $post->ID, 'description_de', true ); if ( 'de_DE' == get_locale() && ! empty( $german )){ return $german; } else { return get_post_meta( $post->ID, 'description_it', true ); } }First of all I would create 2 other variables and declare them, such as $category-german and $tipology-german, than in the “return” I should have something like $category-german, $tipology-german, $german; the return for italian too should be different. Keeping in mind that I could add other languages. Not so many but al least english
The page I need help with: [log in to see the link]
The topic ‘Modifying a function’ is closed to new replies.