How to increase character lengh in blogger snippet instead of using limited length, 'data:post.snippet'?

不打扰是莪最后的温柔 提交于 2019-12-01 00:22:58

You can utilize the data:post.longSnippet data tag which has the limit of upto 300-400 character

<div class='post-body' style='color:black;'>
    <b:if cond='data:post.snippet'><data:post.longSnippet/></b:if>
</div>

Otherwise, if you want to control the exact amount of text that you want to be visible in the snippet, then you can utilize the newly launched operator in the new themes

<div class='post-body' style='color:black;'>
    <b:eval expr='snippet(data:post.body, {length: 450, links: false})' />
</div>

snippet(string, options)

Produces a short snippet from an HTML string.

options: Object specifying the snippeting options, which are:

links: boolean for whether to preserve anchors/links in the snippet. Defaults to true.

linebreaks: boolean for whether to preserve linebreaks (tags) in the snippet. Defaults to true.

ellipsis: boolean for whether to append an ellipsis (…) to the end of the snippet. Defaults to true.

length: Number specifying the maximum length of the snippet.

Change

<div class='post-body' style='color:black;'>
  <b:if cond='data:post.snippet'><data:post.snippet/></b:if>
</div>

To

<div class='post-body' style='color:black;'>
  <data:post.body/>
</div>

It will render your post body with proper HTML markup till any jump break (if exists) or otherwise the full post body.

Consider including jump breaks for all your posts, you can do it through the rich post editor or directly in the post HTML using the code <!--more--> in the exact place where you want the break.

Javascript approaches are not mandatory to retreive post contents, Blogger natively do it.

I hope this is what you are looking for,

 <div class='post-body' style='color:black;'>
   <b:eval expr='snippet(data:post.body, {length: 200, links: false, linebreaks: false})' />
 </div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!