0

Currently I'm using the the_excerpt on my frontpage which works perfectly. When the visiter goes to the post it first needs to read the first part of the story, see a featured image and then load the rest of the content.

Currently I have this:

<?php the_excerpt(); ?>
<?php the_post_thumbnail( 'blog-full', array( 'class' => 'img-responsive img-blog' ) ); ?>
<?php the_content(); ?>

The problem is, the_excerpt loads the same first lines as the_content (it's a duplicate). I inserted a read more tag in WP backend, but it won't cut of the top and start after the tag line.

How do I get this working?

Thanks in advance

2 Answers 2

1

You could do this without having to code anything special. Enter your first piece of text into the Excerpt field in the admin edit screen for the post. Enter only the remaining text into the visual editor.

That way you can have the excerpt text on the site's front page and the "rest" of the text after the thumbnail on the post's single page.

2
  • Need to keep the_exerpt(); .. but this did the trick. Thanks Andy!
    – rwzdoorn
    Commented Aug 5, 2016 at 11:53
  • Cool. Yes, I misread and thought you only wanted the excerpt text on the front! Commented Aug 5, 2016 at 11:54
0

As Documentation says about the_content function, it accepts two arguments. We don't need first, but the second will strip post excerpt from post content (everything before <!-- more --> tag). Your code should looks like this:

<?php the_excerpt(); ?>
<?php the_post_thumbnail( 'blog-full', array( 'class' => 'img-responsive img-blog' ) ); ?>
<?php the_content(null, true); ?>
1
  • And as that same documentation says "The <!--more--> quicktag will not operate and is ignored in Templates where just one post is displayed, such as single.php", which the OP experienced and mentions in the question. Commented Aug 5, 2016 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.