How do I get post ID as a variable when using the_post?
-
Hi, this may seem like a noob question but, I can’t figure out how to get a post ID into a PHP variable!!
I tried using the_ID(); but that just echoed the ID. Trying $post->id but not working!
Here is my code
<?php if(get_post_meta($post->id, 'cover-image')){ ?> <div class="news_image"> <img src="<?php get_post_meta($post->id, 'cover-image'); ?>"> </div> <?php } >
How should I proceed?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How do I get post ID as a variable when using the_post?’ is closed to new replies.