Jump to content

Can't find the children


opalepatrick
 Share

Recommended Posts

For some reason this is not getting the content from the hidden child pages that I was hoping to see.

$staff = $pages->get("/about-us/meet-the-team/, include=hidden")->children;
?>
<div class="row firstrow lastrow">
	<?php
	foreach($staff as $member){
	    echo $member->body;
        }

As you can see, I am trying to publish hidden staff pages as content on a single page. Any clues as to what I am doing wrong?

Link to comment
Share on other sites

Thanks a bunch DaveP. However, I am still not getting any content. Weird. I tried print_r($staff) and got nada as well. Is there a better way to try and spit out the array? I have checked the settings for the pages concerned and they seem fine and refer to their parent and children as I would expect. Baffled.

Link to comment
Share on other sites

Should be:

$pages->get("/about-us/meet-the-team/")->children("include=hidden");

since the children are hidden and not the parent. And also I prefer to get the parent by id since changing the page name would make your selector return nothing. For example if your team page has id 1020:

$pages->get(1020)->children("include=hidden");
  • Like 5
Link to comment
Share on other sites

How about trying `include=all`.   :-X

$staff = $pages->find("/about-us/meet-the-team/, include=all")->children;

That would change nothing since the children() needs the selector. and include=all would also include unpublished children which I guess is not desired.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...