Forums

Getting the parent page id automatically (3 posts)

  1. product247
    Member
    Posted 1 year ago #

    This code below displays a custom field of all child pages of parent page id 19:
    <?php query_posts(array('post_parent' => 19, 'post_type' => 'page')); while (have_posts()) { the_post(); ?><div><a href='' rel="bookmark"><img src="<?php the_field('navigation_thumbnail') ?>" alt="<?php the_title(); ?>"/></a></div><?php } ?>

    Instead of adding the id 19 I want to retreive the current id of the page automatically. Can someone help me with this? Thank You!

  2. Curtiss Grymala
    Member
    Posted 1 year ago #

    Depending on where you're using that code, you might be able to just use $post->ID or possibly $GLOBALS['post']->ID in place of the 19.

  3. product247
    Member
    Posted 1 year ago #

    $post->ID worked perfectly! Thank You

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags