How can I select specific page?

Hi, I am very new to php…
now i am following the tutorial videos… but I have a question.

<div class="left">
            <div class="left-logo">
                <a href="<?= $site->url() ?>"><?= $site->title() ?></a>
                <div class="left-menu">
                <?php foreach ($page->children()->listed() as $works): ?>
                    <ul>
                        <li>
                            <a href="<?= $works->url() ?>"><?= $works->title() ?></a>
                        </li>
                    </ul>
                <?php endforeach ?>
                </div>
            </div>
        </div>

In this code, If I want to select another page, how can I do that?
my structure is,

  1. main page
  2. works page with 5 categories
  3. contact page
    I want to make appear works’s 5 categoris on main page, but I only know $page->children()->listed().
    How can I select works pages 5 categories?
    thanks…

You can get a single page with the page() helper, for example:

if ($p = page('works')):
  foreach($p->children() as $child): 
    echo $child->title();
  endforeach;
endif;

The page() helper needs the id of the page as input.

thanks for reply… but is that php?
Do you know how to link photos or pages in content folder with a tag without php?
I think I can not handle this…
thank you…

Yes, that’s PHP code, I just left out the <?php tag.

<?php
if ($p = page('works')):
  foreach($p->children() as $child): 
    echo $child->title();
  endforeach;
endif;
?>

In what type of field? A textarea field? You can use Kirbytags to link to files and pages. Check out the docs here:

Use the (image: someimage.jpg) tag for images
Use the (link: ) tag for links

But I was under the impression that you wanted to modify the PHP code in your first post, so not quite sure how your question relates to that code.