I am working on a "related content" widget that shows the 3 latest articles with the same tags, with "latest" being determined by a custom field named "articleDate". I can't seem to figure out how to use custom fields in a query of the returned published content. Below is my attempt:
var publishedContent = Umbraco.TagQuery.GetContentByTag(tag);
if (publishedContent.Where(p=>p.Id!=CurrentPage.Id).Count() > 0)
{
@foreach (var item in publishedContent.Where(p=>p.Id!=CurrentPage.Id).OrderByDescending(p => p.articleDate).Take(3)) {
var page = Umbraco.Content(item.Id);
<li class="list-group-item">
<a href="@item.Url">@item.Name
<div class="articleDate">@page.articleDate.ToString("MMMM dd, yyyy")</div></a>
</li>
}
}
TagQuery and custom fields
I am working on a "related content" widget that shows the 3 latest articles with the same tags, with "latest" being determined by a custom field named "articleDate". I can't seem to figure out how to use custom fields in a query of the returned published content. Below is my attempt:
var publishedContent = Umbraco.TagQuery.GetContentByTag(tag);
Hi Andrew
I would like to rewrite this code:
Thanks, Alex!
You are welcome!!!
is working on a reply...