- This topic has 3 replies, 2 voices, and was last updated 4 years, 1 month ago by
Tom.
-
AuthorPosts
-
February 19, 2019 at 2:16 am #814298
Pietro
Hi there,
I’m having a issue showing a custom header on the second language.
In the main language i’ve built few header which will load on all posts of a certain category.
It works fine but in the second language of the post i don’t get the cutom header.I saw a solution of placing this code in functions but it doesn’t work for me, actually it doesn’t show the header on both language.
add_filter( 'generate_header_element_display', 'wpml_generate_header_element_display_filter', 10, 2 ); function wpml_generate_header_element_display_filter( $display, $post_id ) { $current_language = apply_filters( 'wpml_current_language', null ); $element_language = apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $post_id, 'element_type' => 'post_gp_elements' ) ); if ( $current_language != $element_language ) { $display = false; } return $display; }
I’m using your latest version of the theme and all plugins updated.
WP 5.0.2Ps. the posts are only in italian and I’m showing them as translated in english with the WPML option
Thanks
GeneratePress 2.2.2GP Premium 1.7.7February 19, 2019 at 8:38 am #814744Tom
Lead DeveloperLead DeveloperHi there,
We’ll likely need to use a different filter.
For example, create your Header Element for the second language, and leave the Display Rules empty.
Then do this:
add_filter( 'generate_header_element_display', function( $display, $post_id ) { if ( is_category( 'your-target-category' ) && 'en_US' === get_locale() && 123 === $post_id ) { return true; } return $display; }, 10, 2 );
With the code, you would need to update:
1.
your-target-category
with the slug of your category
2.en_US
with the language code you’re targeting
3.123
with the ID of the elementDocumentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 20, 2019 at 3:24 am #815306Pietro
Hi Tom,
thanks for your answer.
I ended up making a copy of all of the headers for the second language, since i had to create another one in any case.
It would be great in the future if you could make it possible to query categories / post etc of both languages.Thanks again
February 20, 2019 at 9:54 am #815787Tom
Lead DeveloperLead DeveloperNo problem!
We’ve had reports that WeGlot handles the translation of the Elements a lot better, in case you ever want to test it.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.