Getting siblings children fields not working

I have a section of my website where I am trying to get the URL of the listed sibling page however it is linking to my sibling’s child. The same button I am trying to only display if there are more than 3 children in the listed sibling.

<?php foreach ($page->siblings()->listed() as $project): ?>
    <?= $project->title() ?>
<?php foreach ($project->children()->limit(3) as $project): ?>
    <div class=" background-image" style="background-image:url(<?= ($f = $project->image()) ? $f->url() : ''; ?>)">
<?php endforeach?>
<?php if ($page->siblings()->count() > 3):?>
    <a href="<?= $project->url() ?>" >
        See More
<?php endif ?>
<?php endforeach?>

I guess there is a typo, you should $project variable:


<?php if ($project->siblings()->count() > 3):?>


<?php if ($page->siblings()->count() > 3):?>
1 Like

Ahh yea this makes sence thanks boss. Any advice with the url, it takes me through to the projects first child? Where I am trying to take it just to the project itself (sibling)

Change variable in second loop, for example use $child to avoid conflict.

<?php foreach ($project->children()->limit(3) as $child): ?>
1 Like

thank you so much, yea i guess labling the variable in the second loop the same is where the issue is. :heart: :heart: :heart: :heart: