Get id of post in loop…?
-
Hi,
I’m trying to list all the current pages Sub pages.
each of those pages has a custom field – “Description”
no prizes for what i’m going to put in that field!heres my code:
<?php $page_query = new WP_Query('post_type=page&post_parent=19'); ?> <?php while ($page_query->have_posts()) : $page_query->the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> <?php $meta_desc = get_post_meta(the_ID(), 'Description', true); echo $meta_desc; ?> <?php endwhile; ?>
so far, it lists the pages, and displays the titles.
where the description should be is just the id of that page, for example “42”
I know that its expected, as im using the_ID() incorrectly.
So, i tested it by putting ’42’ in place of the_ID() which works fine.My question, how do i get the id of the current post in the loop?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get id of post in loop…?’ is closed to new replies.