Read more link is not showing for excerpt

Do I have the syntax correct? If so, the read more link is not showing when added to the excerpt tag. This is what I used: <Field excerpt auto=true more="read more..." />. It is inside of a post loop for a Custom Post Type. Thanks.

Plugin: Loops & Logic 3.1.5
Plugin framework: 20230201.0 in tangible-loops-and-logic/vendor/tangible/plugin-framework
Dependencies: None
Theme: Kadence 1.1.32
Environment: WordPress 6.1.1 PHP 8.1.10

Hi David, welcome to the forum! I can’t say I’ve used the built-in more attribute much myself but I just gave it a shot and I think I see what’s going on. It looks like that automatic “read more” text only ends up getting displayed when the excerpt is automatically generated and when that excerpt is cut off. I bet if you added something like words=5, the default ellipses or your read more text would show up next to auto-generated excerpts. This seems like a bug so I’ll go ahead and have a dev take a look at that.

I expect the reason this didn’t come up sooner is that in most cases you’ll get way more flexibility and styling options by adding a read-more link manually. Plus it’s not much extra effort. Here’s how I’d do that:

<Loop type=post count=3>
  <p>
    <Field excerpt auto=true /> <a href="{Field url}">Read more...</a>
  </p>
</Loop>

Let me know if that works for you. I’ll follow up here when I hear back from a dev about that potential bug with the more attribute.

Actually, I think I might be wrong and this isn’t actually a bug. The docs note that the more attribute is designed to specify what text should be displayed after content is trimmed. It’s not intended to be used to add a “read more” link as you and I and some other folks had assumed. It seems even the main developer might have lost sight of this when this user request was implemented last year which hyperlinked the text written inside the more attribute.

This trimming only happens on auto-generated excerpts and only when you specify a max number of words. This explains why it wasn’t getting displayed in your case when you hadn’t specified a max number of words. It also explains why it wasn’t getting displayed on non-auto-generated excerpts since these would never be trimmed and would just display whatever is written in the excerpt field of that post.

So I think 99% of the time you’d want more="..." so that when an auto-generated excerpt gets trimmed it ends with nice ellipses instead of ending mid-sentence. I suppose some languages might not use ellipses on trailing sentences so that attribute exists for those rare cases. And then if you wanted a read-more link, you’d write it the way I suggested with an a tag.

Thanks for bringing that up, I hadn’t really realized why that attribute was there and I had always assumed just like you that it was a slightly weird way to add read more links. So thanks for prompting me to learn something new!

2 Likes

Thank you for that clarification. Yes, a regular link does the job.

1 Like