Read more option not appearing in translated posts
-
Hi, my default language is working fine but in translated language when I visit home page, I can see full posts. I had inserted Read More tag on each posts. There should be Read More button after certain paragraphs.
-
Hi,
you put the readmore button in the translation too ?
Can you make a screen capture of the translation and the readmore
Stéphane
yes, I did insert read more in the translated too but it does not appear in translated one. Heres the link for original language. And this is the link for translated one.
You can see that there is read more option for each posts in original language but in translated language full posts appears instead of partial with read more option.
Can you send a screen capture of the bakckend , to show me how you set it.
fron-end show me only the result.Stéphane
here is the screenshot of my posts in backend link to screenshot
hello, why I am not receiving any support reply? I can see except me all other are getting reply in time. And for me its been more than a week and no reply in regards to my issues.
I have reproduce the problem but i don’t have yet the solution to fix this readmore link
Stéphane
Hi,
I have a fix for this problem
1) add a filter in Falang (i will add it in the 1.3.27 falang version)
2) add the filter in function.php of your template1) add in wp-content/plugins/falang/public/class-falang-public.php
line 996 you have to modify like this the function translate_post_content
if ($post && !$this->is_default() && $falang_post->is_post_type_translatable($post->post_type)){
$content = $falang_post->translate_post_field($post, ‘post_content’, $this->current_language, $content);
/*
* @since 1.3.27 add filter for content (use for readmore text)
* */
$content = apply_filters( ‘falang_translate_post_content’, $content );}`
2) in the function.php you can put this
function falang_translate_post_content($content){ if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) { if ( has_block( 'more', $content ) ) { // Remove the core/more block delimiters. They will be left over after $content is split up. $content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content ); } $_post = get_post(); $output = ''; $content = explode( $matches[0], $content, 2 ); if ( ! empty( $matches[1] ) ) { $more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) ); } $output = $content[0]; if ( count( $content ) > 1 ) { if ( ! empty( $more_link_text ) ) { $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text ); } } $output = force_balance_tags( $output ); return $output; } return $content; } add_filter('falang_translate_post_content','falang_translate_post_content');
`
the falang_translate_post_content is not yet perfect but work on my system
Stéphane
thank you for your reply. are you trying say that if I need to resolve this issue now, I have to do some changes in .php or if I wait for next update of plugin no need to do any change. Once plugin in updated to latest version this will be resolved automatically?
No,
I will add this filter to falang plugin , no change will be necessary after the update.
the specific code i send you is not overrided by Falang update because it’s in your template function.php
i will solve completly this issue directly in falang but probably not in the next release.
Stéphane
thank you very much for your help. I am wondering if this issue is coming only in my site or in others site too. Does theme affect in anyway in this kind of issues. Thank you.
Hi, I have added the code in my function.php and in plugins as well but it did not appear read more text. Do I have to replace or add filter in step 1? Do i have to just add this code there?
$content = apply_filters( ‘falang_translate_post_content’, $content ); }
As its not clear above what is the exact code to add.
Thank you
you have the all the code to add from the previous post
1) code in function.php
2) add line in the falang_public.phpStéphane
I add the code in function.php in my theme but code you wrote to write in falang_public.php is not clear as it is not in the code box the code is in plain text with other description so I could not figure out the exact code.
I tried with the code given 2-3 times byntrying this or that way but it did not work.
Please could you provide me the exact code for it inside the code box. thank you.
Wait the next update i will publish it soon,
i put bellow the full functionpublic function translate_post_content($content) { global $post; $falang_post = new \Falang\Core\Post($post->ID); //TODO add something to filter which post_content needs to be non-translated //Divi edition page doesn't translate content if (isset($_GET['et_fb'])){return $content;} //check why yootheme builder doesn't translate it if ($post and $post->builder = preg_match('/<!--\s?{/', $post->post_content)) { return $content; } //another check on yootheme builder if ($post and preg_match('/<!-- Builder/',$content)){ return $content; } if ($post && !$this->is_default() && $falang_post->is_post_type_translatable($post->post_type)){ $content = $falang_post->translate_post_field($post, 'post_content', $this->current_language, $content); /* * @since 1.3.27 add filter for content (use for readmore text) * */ $content = apply_filters( 'falang_translate_post_content', $content ); } return $content; }
Hi I have updated the plugin to latestone and while updating it shows message that said read more function has been fixed. But still full post is being displayed in translated language. I tried with putting the code in function.php too but did not work.
Could you please let me know again with the steps and actual code if needed. Thanks
- The topic ‘Read more option not appearing in translated posts’ is closed to new replies.