Subscribe to Our Newsletter

x

posts

Display one or more posts inside an .xml file.

<posts name="homepage_posts" format="posts_popular" source="frontpage" limit="10" section_url="entertainment" />

Variants

<posts_without_current />

It is used the same way as <posts>, but excludes the current post (on a post page). When using <posts_without_current> you must define the limit attribute (see below) with 1 more than you actually need.


Attributes

  • name - define the name of the section. Required for displaying unique posts using the <posts_without_current> tag.
  • format - defines the mustache template that will be used to render each post, relative to engine/mustache/roar/posts/ directory.Usage: create a new .html template file inside the above directory (ex: posts_most_read.html). Use <posts format="posts_most_read"> inside an .xml file to render this type of posts.
  • template - defines the mustache template that will be used to render each post, relative to engine/mustache/ directory.
  • source - post source used to fetch data from. (default is "frontpage"). It can take one of the following values:
    • frontpage - load posts for front page or any other subpage (section);
    • search_result - load posts that are result of some search;
    • tag - load posts for specified tag;
    • popular - load most popular (most read) posts for last 3 days;
    • related - load related posts (calculated by similar tags); if there's no related posts, then populate it with posts from the same section;
    • mentioned - load mentioned posts (if current post has any internal links, i.e. links to posts on the same domain, then this posts will be "mentioned" for current post).
  • limit - maximum number of posts to show in this block.
  • css_classes - add additional css classes for the posts wrapper.
  • section_url - name of the section used as source for posts.
    • If source="popular", you can specify more than one section separated by comma.
    • On article page you can use post's section as a base for displaying posts from the same section. Usage:
    • <posts_without_current format="posts-main" section_url="{{post.section}}" limit="4" />
  • no_posts_template - set a path to a jinja template that will be shown when no posts are found.
  • source_site - site used as source for posts. Use source_site="parent_site" on community pages so you can pull popular posts or posts from other sections with section_url="section-name".
  • section_template - define the template to be used for the posts wrapper (container). Default template located at: engine/community/roar/blocks/section.
  • source_unique - true OR false Posts among any source with this attribute are unique. For example if we have posts with ids [1,2,3] for frontpage source and posts with ids [3,4,5] for 'popular' source, 'popular' source excludes post 3 from its list and it becomes [4, 5].
  • tag_name - only relevant if source="tag". Name of the tag that will be used as source for posts (default to current tag on tag page).
  • exclude_section - way to omit posts (which are in certain section) when using popular source. Usage:
  • <posts format="popular-food" source="popular" exclude_section="fruits" />
  • filters - apply filters to posts. In order to minimize data transfer, your <posts> tag will not include all the data you may expect, such as author name or the section title this post belongs to. Use these filters to get more data about your post:
    • frontpage_tag - take the first tag from public_tags of the post and assign to 'frontpage_tag' key on the same post;
    • original_user_subsite - add author data to your post;
    • section - add section info on the post. If the post has multiple sections, the first not private section in the list will be returned. Usage:
    • <posts name="splash" format="splash_news" source="frontpage" filters="section" />
    • display_disclaimer - set the display_disclaimer attribute of the post to "True";
    • pretty_date - apply this function to this post. Usage:
    • <posts name="news2" format="news" source="frontpage" limit="4">  <filters>    <pretty_date field_name="created_ts" full_format="true" enable_future="false" date_format="%a, %d %b %Y %H:%M:%S +0000" new_field_name="created_ts_formatted"/>   </filters></posts>
      Now you should be able to use {{created_ts_formatted}} in your mustache template. Attributes of pretty_date:
      1. field_name required string - name of the field on the post for processing
      2. full_format optional boolean default - false.
      3. enable_future optional boolean default - false.
      4. date_format optional default - "%d %B %Y".
      5. new_field_name optional default - field_name. Name of the field on the post model where result of filter will be written. By default it will be written in the same field_name.
    • set_image_size - set the image_url context variable for desktop and/or mobile screen. Usage:
    • <posts name="popular" format="popular" source="popular" limit="1" section_url="popular">    <filters>        <set_image_size url="image528x304,image600x" mobile_url="imageWWWxHHH,image300x"  />    </filters></posts>

      You should now be able to include {{image_url}} in your mustache template

    • partial - override any partial used in your mustache template for post rendering. Example:

    • <posts name="news" format="news" source="frontpage" limit="6">    <partial name="roar/posts/partials/author/author" replace_with="custom/author"/></posts>

Applying filters

Set them in the filters attribute (if there are more than 1 filter to define, separate them with comma, no spaces allowed). Example:

<posts name="news" format="news" source="frontpage" limit="6" filters="frontpage_tag,display_disclaimer"/>

Set them in the <filters> child tag. Example:

<posts name="news" format="news" source="frontpage" limit="6">  <filters>    <frontpage_tag/>    <display_disclaimer/>  </filters></posts>

It is also acceptable to define filters both ways into a single <posts> tag. Example:

<posts name="news" format="news" source="frontpage" limit="6" filters="frontpage_tag">  <filters>    <display_disclaimer/>  </filters></posts>

How to Include Interactive Elements in Posts

Enhance your articles with rich and creative media

Every article is a fresh chance to grab new readers and nurture loyal followers. This is why we give creators every opportunity to build content rich with media elements that enhance every reader's experience.

Add More Layers to Your Content

You can easily add interactive elements, like charts, to posts on our platform. For example, if you need to embed iframe code into a post, this can be done via our Add Media Bar. To do so, click the code icon (< >):

A text box will appear so you can insert your code:

Embedded Code Across Platforms

One important thing to keep in mind is that Google AMP, AppleNews, and Facebook Instant Articles will not always support embedded code. So if you use an iframe, it's best to turn off distribution to those channels for that particular post. If you have a lot of posts that require embedded code, this could be problematic for growth across those important platforms.

If you do want to use an iframe on a post destined for Google AMP distribution, it can be possible if the iframe is not at the top of the page or within the first 75% of the viewport when the page is scrolled to the top (whichever is smaller). AMP is a fast technology designed for mobile users and iframes are loaded using arbitrary timing that AMP's technology cannot ensure. For this reason, it's suggested that iframes be included in places that are not visible by users upon load.

If you have an article that needs to include an iframe at the top of the page, or within the first 75% of the viewport, AMP can be turned off for that individual article within Entry Editor.

If you don't need an interactive chart to be interactive in nature, can turn it into an image and upload it directly to your post. This way it will work on all platforms, including Google AMP, Apple News, and Facebook Instant Articles. This option, when possible, is ideal to ensure you're optimized for page speed.

Take Advantage of Shortcodes

Another great way to embed media is through our shortcodes functionality. Click here to learn more about shortcodes. Shortcodes can also inserted using the Add Media Bar. Click the brackets icon ([ ]) to choose the shortcode you want to use.

Here's an example of a chart on an article page that's been inserted using a shortcode:

If you have any questions about how to add interactive elements to your content, please email support@rebelmouse.com or talk to your account manager today.

Shortcodes Dashboard: Dynamic Media in Just a Few Clicks

Create multidimensional content with easy-to-find shortcodes

We believe static media is dead, and that every piece of content should be multidimensional and engaging. This is why our platform enables creators so they can add dynamic media to their content in easy and efficient ways.

One simple way to add interactive content to any post is through the use of shortcodes. Shortcodes are small snippets of code that are easier to remember than longer sequences. They typically will activate a feature or embed media into an article.

Keep reading... Show less
Subscribe to Our Newsletter