How to get an article description or excerpt within Expression Engine
-
03-06-2021 - |
Question
I saw in Expression Engine I can use {embed:title} and {site_name} variables, but now I need a variable to pull an excerpt or description of the article itself. Is there such a variable/tag?
Solution
ExpressionEngine tags are based solely on custom fields which you yourself have defined. So in the field group for your "articles" channel, you'll have some fields, maybe {article_summary}
, {article_body}
, {article_image}
, etc. To display your summary, just use {article_summary}
in your template.
I'm assuming that you're coming from something like WordPress maybe, where every piece of content has the_content()
and the_excerpt()
... aside from a handful of global variables, and some fields which are universal to all entries (like {title}
, {entry_date}
, etc), ExpressionEngine isn't like that. You define what fields you use for each channel - you have complete control.
OTHER TIPS
Here is the actual code you have to include in your EE template.
{exp:channel:entries channel="article" limit="5" dynamic="no"}
<div class="home_thumb">
<h1><a href="{title_permalink="post/articles"}">{title}</a></h1>
<div class="home_thumb_img">
<a href="{title_permalink="post/articles"}"><img src="{article_image}"></a>
{if article_content}
<p>{article_content}</p>
{/if}
</div>
</div>
{/exp:channel:entries}