How can i load specific page?

<?php snippet('header') ?>
    <div class="category">
        <?php foreach ($page->children()->listed() as $works): ?>
            <ul>
                <li>
                    <a href="<?= $works->url() ?>"><?= $works->title() ?></a>
                </li>
            </ul>
        <?php endforeach ?>
    </div>

    <section class="wrap">
        <?php foreach ($page->children()->unlisted() as $works): ?>
                <img src="<?= $works->image()->url() ?>">
        <?php endforeach ?>
    </section>
<?php snippet('footer') ?>

Hi, I am just following video tutorials… and I have problem…
In my code, I can only see 1 photos… there is 5 photos…

I want to make appear 5 photos in ‘main’ folders on main page,
and in ‘works’, there is 5 categories…

but with this code, can not appear any photo on main page.
how can i fix this?

thanks…

or, how can i load specific page? instead of " <?php foreach ($page->children()->unlisted() as $works): ?>
"?
thanks.

This code always gets the first image in a page, not multiple. Otherwise, if you want all images in a page, you would have fetch them using images() instead of image(), and then loop through them.

<?php foreach ($page->children()->unlisted() as $works): ?>
  <?php foreach( $works->images() as $image ) : ?>
      <img src="<?= $image->url() ?>">  
  <?php endforeach ?>
<?php endforeach ?>

Don’t know if that makes sense in the context of the categories, though.

Hi! thank you very much! It works…!
can i ask one more thing?
if I want to make them appear on main page, how can I link?
I made home.php and copy them but nothing appear…
thanks…

and one more last last question,
in this code…

if i want to select specific image like ‘01_image.jpg’, what should i do…?

You would have to fetch the page by name, so instead of $page:

in home.php

<?php if ($p = page('works')): ?>
  <?php foreach ($p->children()->unlisted() as $works): ?>
    <img src="<?= $works->image()->url() ?>">
  <?php endforeach ?>
<?php endif ?>

You can pass the image name to the image method (example inside the loop using the $work variable:

<?php if ($image = $work->image('01_image.jpg') ): ?>
   <img src="<?= $image->url() ?>">  
<?php endif ?>