• In my blog https://www.drteddy.gr in the front page the template displays the excerpt of the post.

    I want to display the_content() of the post depending on the number of the words of the post. I’ve coded a function that counts the post’s words, but I couldn’t implement the part I describe above.

    Could anyone give me a clue or help?

Viewing 3 replies - 1 through 3 (of 3 total)
  • try This

    $max=40;
    if ($count> $max) {
    
    the_excerpt();
    }
    
    else {
    
    the_content();
    }

    Thread Starter drteddy

    (@drteddy)

    It doesn’t work….

    For some reason the if statement always returns the part of the code that included in “else” section….

    Giving some more tries…

    I’ve coded a function that counts the post’s words

    instead of $count use the returned value from that function (don’t use echo in your function , but use return).

    possibly post the code of that function here – see forum guidelines for posting code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display the_content() or the_excerpt() conditionally’ is closed to new replies.