• I have a single post on my homepage ( https://www.roobottom.com ) and below this I have a custom script that get 5 of the most recent posts.

    I need to know how to get the id of the post on the homepage so I can pass it to the recent post script so it’ll miss out that post from the top of the list and get the next five.

    I know I could get this from the URL $p parameter, but i’m using permalinks.

    any help would be great! Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • just a guess.. but I think you should be able to use ‘$post_id’ within the loop, passing the value of it to a variable. Then, use that variable as an exclusion within the custom get 5 recent post scripts?

    Thread Starter roobottom

    (@roobottom)

    I tried echo’ing the var $post_id in the loop, but nothing happened. This would be most useful if we could access the var’s for each database field for each post with a variable!

    Any other ideas? Thanks!

    I had a few moments.. gave it a go as well.. and well, I got nothing as well… I looked at a plugin I am using that uses the same syntax $post_id and although it works there, I can’t get it to work within the loop, so I am honestly left scratching my head… sorry. anyone else have any ideas?

    You can use <?php echo $post->ID ?> to output or use the current post ID.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get current post id?’ is closed to new replies.