Missing continue reading button
-
Hi. I’m sorry to post a topic after another but I’ve got a very bad problem. Full posts were displayed in the homepage instead of showing just a paragraph with the “continue reading” button.
There was a user with my exact issue and he was told to add a code in the functions.php file. I did it and it basically worked but… Posts are now showing without the “continue reading” button. But the biggest problem is that every time I open an article to fully read it, I can see only a paragraph. The rest of the content is lost.
Please let me know hot to solve the problem. Thank you.
-
One last thing. If this can help, I tried to change various themes and until now only one seems to work: Twenty Twenty-One. Continue reading button is showed and the article is complete when I click on it to fully read it.
Hi,
What is your template ? can you post a screenshot ?
i will repost here the solution and see if i can integrate it in a next Falang version out of the box.
Stéphane
Thanks for replying. I currently use this theme, Lavander Lite.
Hi,
i have check and it’s work like before just add this to your function.php
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>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');`
Stéphane
-
This reply was modified 3 years, 10 months ago by
sbouey. Reason: type for the code
Hi Stéphane and thank you very much for your support. I’m sorry to bother but I couldn’t even try if the code works because when I save the change I see this error:
syntax error, unexpected 'falang_translate_post_content' (T_STRING), expecting ')'I just don’t get it. The code I took from the old topic doesn’t return any errors.
Again, if this can help, I noticed that the problem is this piece of code:
if ( ! empty( $more_link_text ) ) { $output .= apply_filters( 'the_content_more_link', ' <a>ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );Conversely, the old one works fine and doesn’t return any errors:
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 );Perhaps a problem in the copy/paste in the thread, if you know a sharecode site where i can put the code it can make it
i have see codeshare but it’s need registration and code expire in 24h
Stéphane
Well I’ve found this BB Code generator. You could use the [code][/code] tag and copy and paste the code here.
Yes it was i have done the first time, i can put it another time
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');-
This reply was modified 3 years, 10 months ago by
sbouey.
Hi Stéphane. You posted the old code, the one that doesn’t return any errors. I already tried it as I wrote before but it doesn’t solve my problem. The “continue reading” button is missing and the translated articles only show one paragraph insted of the full text…
I wanted to try the new one, but as I told you it returns that error. What should I do now?
Hi,
Do you have a link to your site or screen capture of the funcion.php , i have checked another time and it’s work perfectly locally on the woodmart template.
Stéphane
Hi,
I have found the problem , it’s when the gutenberg more read text is empty (default case)
in this case nothing is displayed.
I give you a solution soon.Stéphane
All seems to work fine with the last code you gave me. Thanks again for everything.
set the thread as resolved
-
This reply was modified 3 years, 10 months ago by
The topic ‘Missing continue reading button’ is closed to new replies.