One of my posts has the following content:
This is a test post. Nothing more,
nothing less.
Three lines before the jump
<!--more-->
And a couple of more lines
after the jump.
Note: these were written as you see them, in the WP editor, using the HTML tab - so we have no hidden <br>
or anything else going on in the post content.
Also: No Manual Excerpt was defined for this post.
If I use the_content()
, I get this:
<p>This is a test post. Nothing more,<br />
nothing less.<br />
Three lines before the jump</p>
<p><a href="...#more-1336" class="more-link" title="Continue Reading">»</a></p>
If, however, I use echo get_the_excerpt();
I get this:
This is a test post. Nothing more, nothing less. Three lines before the jump
No <p>
s, nor <br />
s (heck, not even the [...]
I was half-expecting!)
What I'd really like to achieve in my theme is (within The Loop, of course):
- If a manual excerpt exists: display
that (and I know I'll have to tweak
the
[...]
) - Else, display the
content, respecting any
<!--more-->
you may find.
So, I was starting with this
$excerpt = get_the_excerpt();
if($excerpt=='') { //right, isset or empty may be better
the_content();
} else {
echo $excerpt;
}
But I'm getting the feeling there's a better way? Or is there a quick fix for the formatting issue mentioned above?