1

Something strange when I am developing my own theme.

Not sure what have I changed recently, but the the_excerpt() or get_the_excerpt() started to show full text on my localhost dev environment, while on my web (actual working website online) it looks just fine, showing excerpts with "more".

I compared and pull my files from my web server to local computer, still, the_excerpt() shows full text instead of `excerpt.

So what else should I look into? What might have caused the localhost server to suddenly ignores the_excerpt() and shows full text instead(as it did on remote server online)? The files should be the same.

<div class="entry-excerpt">
<?php
        $my_excerpt = get_the_excerpt();
        if ( '' != $my_excerpt ) {
            echo $my_excerpt; 
        };
?>
</div>

In localhost the above code prints full content of the post instead of excerpt.

In remote server however, the same code prints the excerpts correctly with a "more" button.

  • It sounds like it might be showing you an error message instead, can we see the full message? And the code in question? – Tom J Nowell Jul 19 '18 at 18:50
  • I have edited the post to show you the code. it's simple code really. I am not getting any error messages, nor any errors show up in the console. In localhost it simply prints full content instead of just the excerpt (behaving like the_content()). I also tried the_excerpt() instead and the result was still the same. That said, it behaves normally on a remote server online. – adrian li Jul 19 '18 at 19:43
  • and you're absolutely sure the two environments are running identical code? With the same settings in WP Admin? There's nothing environment based that would do this – Tom J Nowell Jul 19 '18 at 19:44
  • As an aside, is there a particular reason you didn't use the_excerpt()? – Tom J Nowell Jul 19 '18 at 19:47
  • yea the code are the same. i pull all the files from server(including function.php and all) to localhost and still get the same result. I am not sure what in the admin panel could have changed that since I shouldn't have make any changes at all. I didn't use the_excerpt() because my theme's base file was generated from underscores.me and I leave it as is since that might be best practice considering it was developed by the guys who made wordpress. – adrian li Jul 19 '18 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.