Sachin B. R.
Sachin B. R.

Reputation: 959

How to get an array of Sitecore Sibling Items?

I want to get an array of all the sibling items of the current item so that I can display the thumbnails in them. how can I achieve this?

Thanks in advance.

Upvotes: 2

Views: 1902

Answers (1)

Marek Musielak
Marek Musielak

Reputation: 27132

You can get parent item of the current item and then take all its children except from the current item.

You can use code below:

Item currentItem = Sitecore.Context.Item;
Item[] siblings = currentItem.Parent.GetChildren().Where(c => c.ID != currentItem.ID).ToArray();

Upvotes: 8

Related Questions