Get Content
With nothing but a URI, or list of URIs, you can fetch all available data regardless of the content type. It is a friend to pages, entries, and taxonomies alike.
Example
Let’s use the Redwood demo site as an example. Say we want to fetch the Niles Peppertrout’s “Fun Facts” and display a random one in the footer of our site.
If we looked at the about/index.md
page we would see that there’s a variable list called fun_facts
. That’s what we want.
In addition to the get_content
tag, we’ll be using the shuffle and limit modifiers to get one item from the list at random, and the join modifier to collapse an array into a string. This is just one of many ways you could achieve the same result.
{{ get_content from="/about" }}
<blockquote>
{{ fun_facts | shuffle | limit:1 | join }}
</blockquote>
{{ /get_content }}
Shorthand syntax
You may also use a shorthand syntax, where the second tag part refers to a variable. This variable should hold the URL or ID of the content you’re fetching.
page: /about
{{ get_content:page }}
...
{{ /get_content:page }}
Parameters
from
string |
Pass a local URI or ID as a literal string, variable, or pipe delimited list, and all retrieved data will be available inside the tag pair. |
---|---|
limit
integer |
Limit the total results when fetching multiple content files. |
offset
integer |
Offset the total results when fetching multiple content files. |
show_unpublished
boolean false |
Unpublished content is, by it's very nature, unpublished. That is, unless you show it by turning on this parameter. |
show_future
boolean false |
Date-based entries from the future are excluded from results by default. Of course, if you want to show upcoming events or similar content, flip this switch. |
show_past
boolean true |
Date-based entries from the past are included in results by default. |
sort
any fieldname |
Sort results by any fieldname when fetching multiple content files. |
locale
string |
Show the retrieved content in the selected locale. |