I'm having some difficulties returning the sibling pages that have the same field value.
<?php
#SET VARS
$locationData = $page->get("LocationData");
# Get Sibling pages, except current one
$sibPages = $page->siblings("id!=$page");
# For each them
foreach ($sibPages as $sP) {
# Return Sibling pages that share the same "LocationData" field value
$sP = $pages->find("LocationData=$locationData");
# Another Loop
foreach($sP as $sPP) {
echo $sPP->title .'<br />';
}
}
?>
Page structure
Parent Page
- Child Page1 (locationData=foo)
- Child Page2(locationData=bar)
- Child Page3(locationData=foo)
- Child Page4(locationData=foo)
My desired output would be if I'm on child page 1, to return child page3, and child page4 because they have the same identical field value and are also a sibling page. Instead the output returns me Child page 1, child page 1, child page 3 child page 3, child page 4, child page 4 while being on child page 1. I understand this is happening because of my 2 foreach loop's but I'm not sure how to filter by $page then filter again by $pages.
TL;DR My end goal is to return sibling pages with the same field value, except the current page