diff --git a/src/Umbraco.Core/Xml/UmbracoXPathPathSyntaxParser.cs b/src/Umbraco.Core/Xml/UmbracoXPathPathSyntaxParser.cs index 87d4d459faf7..a3b194226c3e 100644 --- a/src/Umbraco.Core/Xml/UmbracoXPathPathSyntaxParser.cs +++ b/src/Umbraco.Core/Xml/UmbracoXPathPathSyntaxParser.cs @@ -136,12 +136,12 @@ public static string ParseXPathQuery( }); } - // These parameters must have a node id context - if (nodeContextId.HasValue) + if (nodeContextId.HasValue || parentId.HasValue) { + var currentId = nodeContextId.HasValue && nodeContextId.Value != default ? nodeContextId.Value : parentId.GetValueOrDefault(); vars.Add("$current", q => { - var closestPublishedAncestorId = getClosestPublishedAncestor(getPath(nodeContextId.Value)); + var closestPublishedAncestorId = getClosestPublishedAncestor(getPath(currentId)); return q.Replace("$current", string.Format(rootXpath, closestPublishedAncestorId)); }); }