Forum Moderators: open
What is strange to me is that it does not cut off in the middle of HTML code... I even have it set up to wait until the end of a sentence. Here is the code of the post that shows when it is truncated:
<img class="size-full wp-image-988 alignnone" src="http://example.com/wp-content/uploads/2008/10/coffee500.jpg" alt="Fair Trade Coffee" width="500" height="333" />
<h3>I'm a coffee snob.</h3>
<h3>I buy only organically grown coffee, I always buy locally roasted coffee, and I only buy Fair Trade coffee.</h3>
<h3>Why?</h3>
Coffee is a luxury item, imported from far away and grown (usually) through the exploitation of the people and environment that produce it. Exploitation of humans and of the Earth really clashes with my worldview.
As you can see, it truncates at the end of a sentence. Following that sentence is another sentence, no code for 27 words after.
On the front page of the site, when this post is truncated, the next line of code is a permalink to the full post. The problem is, the permalink on this post is loading as http://example.com/<?php the_permalink() ?> rather than http://example.com/fair-trade-sustainable-future
This does not occur with any other posts.
I allow code in the truncated posts and take care to make sure they are not cut off in the middle of code. I did, however, try disallowing code to see if that resolved the problem, and it did not.
The validator returns this error:
_________________
# Warning Line 195, Column 266: character "<" is the first character of a delimiter but occurred as data.
…<div class="postlinks-left"><a href="<?php the_permalink() ?>" rel="nofollow"
This message may appear in several cases:
* You tried to include the "<" character in your page: you should escape it as "<"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.
___________________
As you can see by the code from the post, there is no unescaped ampersand or anything like that. The problem is not with the coding of the template, which is the HTML you see in the error, because this would cause issues with all posts and it does not.
Am I missing something easy?
BTW, Doctype is XHTML Transitional.
<div class=\"postlinks2\" style=\"clear:both;\">
<div class=\"postlinks-left\">
<a href=\"<?php the_permalink() ?>\" rel=\"nofollow\"><u>Continue Reading...</u></a>
</div>
<div class=\"postlinks-right\">
<div class=\"commentslink\">
<?php comments_popup_link(); ?>
</div>
</div>
</div>
This is how it is loading:
Coffee is a luxury item, imported from far away and grown (usually) through the exploitation of the people and environment that produce it. Exploitation of humans and of the Earth really clashes with my worldview....
<div class="postlinks2" style="clear:both;">
<div class="postlinks-left">
<a href="<?php the_permalink() ?>" rel="nofollow"><u>Continue Reading...</u></a>
</div>
<div class="postlinks-right">
<div class="commentslink">
<?php comments_popup_link(); ?>
</div>
</div>
</div>
When it should be loading like this:
Coffee is a luxury item, imported from far away and grown (usually) through the exploitation of the people and environment that produce it. Exploitation of humans and of the Earth really clashes with my worldview....
<div class="postlinks2" style="clear:both;">
<div class="postlinks-left">
<a href="http://example.com/fair-trade-sustainable-future" rel="nofollow"><u>Continue Reading...</u></a>
</div>
<div class="postlinks-right">
<div class="commentslink">
<a href="http://example.com/fair-trade-sustainable-future/#comments" title="Comment on Fair Trade for Social Justice and a Sustainable Future">10 comments</a>
</div>
</div>
</div>
All other posts that are truncated in this manner load as they are supposed to.
I worked around it by removing my custom excerpt and using the Advanced Excerpt plugin.
Problem solved, although I'm still curious as to why a post being written by one author would invalidate a page but not when written by another author...
The escapes on the quotes in the php seems to indicate it's part of a string, (or however your CMS templates work). Hence you cannot use <?php ...?> in there (it'll not be executed but interpreted as part of the string unless the system processing your template anticipates this.
Personally I think your problem is more a CMS one than a pure validation issue. Validating generated code isn't just about validating a sample, but also being sure the entire processing keeps it valid.