Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Filtering Blog entries by tag



I want to be able to filter blog entries by tag but cant figure out how. I can see that there is something called TagCriterion that could be used. If so, how?


Aug 04, 2010 15:29

Is this related to the Blog templates in EPiServer demo package or EPiServer Community?

Aug 05, 2010 9:50

We are using Relate+ and CMS 5. What I am looking for is a code sample for how I can filter out all entries for a certain blog object with a certain tag name.


Aug 05, 2010 11:10

Does anyone know how to solve this? The documentation states to use TagHandler.Instance.GetTaggedItems but there is no Instance member variable in TagHandler and the GetTaggedItems is declared as internal. 

Please advise.

Best Regards,

Tobias Jakobsson

Sep 13, 2010 14:11

Finally have a solution for this. Below is a code example of a function that finds entries in a blog with a specified tag:


        public static EntryCollection GetEntriesByTag(Blog blog, string tagString, int page, int pageSize, out int totalItems)
            EntryQuery entryQuery = new EntryQuery();
            entryQuery.Blog = new BlogCriterion();
            entryQuery.Blog.ID = new IntegerCriterion();
            entryQuery.Blog.ID.Value = blog.ID;

            // Create a TagCriterion
            TagCriterion tagCrit = new TagCriterion();
            tagCrit.Name = new StringCriterion();
            tagCrit.Name.Includes = new StringInCriterion();

            // Create a entityTagCriterion, and use the TagCriterion created
            EntityTagCriterion entityTagCriterion = new EntityTagCriterion();
            entityTagCriterion.Tag = tagCrit;

            // Finally, set the Tags property
            entryQuery.Tags = new TagCollectionCriterion();
            entryQuery.Tags.Containing =  new MultipleEntityTagCriterion();

            entryQuery.Created = new DateTimeCriterion();
            entryQuery.OrderBy.Add(new CriterionSortOrder(entryQuery.Created, SortingDirection.Descending));

            EntryCollection entries = BlogHandler.GetQueryResult(entryQuery, page, pageSize, out totalItems);
            return entries;


What was a bit tricky to figure out was that you should use both TagCriterion and EntityTagCriterion, and how these correlate.

Happy coding!

// Regards, Torbjörn Stavås

Edited, Sep 30, 2010 21:43

Thanks. Just what I was looking for.Works like a charm.


Kind Regards


Jun 12, 2011 14:40
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.