• Resolved fabykennedy

    (@fabykennedy)


    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.

Viewing 15 replies - 1 through 15 (of 24 total)
  • Thread Starter fabykennedy

    (@fabykennedy)

    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.

    Plugin Author sbouey

    (@sbouey)

    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

    Thread Starter fabykennedy

    (@fabykennedy)

    Thanks for replying. I currently use this theme, Lavander Lite.

    Plugin Author sbouey

    (@sbouey)

    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 2 years, 4 months ago by sbouey. Reason: type for the code
    Thread Starter fabykennedy

    (@fabykennedy)

    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.

    Thread Starter fabykennedy

    (@fabykennedy)

    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 );
    Plugin Author sbouey

    (@sbouey)

    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

    Thread Starter fabykennedy

    (@fabykennedy)

    Well I’ve found this BB Code generator. You could use the [code][/code] tag and copy and paste the code here.

    Plugin Author sbouey

    (@sbouey)

    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 2 years, 4 months ago by sbouey.
    Thread Starter fabykennedy

    (@fabykennedy)

    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?

    Plugin Author sbouey

    (@sbouey)

    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

    Thread Starter fabykennedy

    (@fabykennedy)

    Plugin Author sbouey

    (@sbouey)

    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

    Thread Starter fabykennedy

    (@fabykennedy)

    All seems to work fine with the last code you gave me. Thanks again for everything.

    Plugin Author sbouey

    (@sbouey)

    set the thread as resolved

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Missing continue reading button’ is closed to new replies.