add content every 3 posts on Tumblr

社会主义新天地 提交于 2019-12-06 08:22:01

问题


I would like to know if there is a way to put content after 3rd post on every page so I can render something... I don't find anything on tumblr theme API


回答1:


Specific Post With API

If you are using the API to gather / append posts this would be left for you to do. A simple loop / count should be enough to determine the third post.

Specific Post With Themes

If you are creating a Tumblr theme, there is a theme operator / block to cater for this:

{block:Post[1-15]} 
  /* Add something to the post [1-15] on each page */
{/block:Post[1-15]} 

Rendered for the post at the specified offset. This makes it possible to insert an advertisement or design element in the middle of your posts.

Question Specific Answer

OP states after the 3rd post, to do this include the block at the very end of the {block:Posts}{/block:Posts} loop.

{block:Posts}
  /* All your layout / post logic here, making sure 
     there is nothing left to render */
  {block:Post3}
    /* Add something directly after the third post on each page */
  {/block:Post3}
{/block:Posts}

Reference

Post Theme Operators: http://www.tumblr.com/docs/en/custom_themes#posts



来源:https://stackoverflow.com/questions/21573814/add-content-every-3-posts-on-tumblr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!