I’m trying to get specific post to display in a single.php page, however for some reason I get all posts displayed. I’m not sure if I am getting post id correctly, but here is how I do it at the moment:
<?php
$post_id = (int) $_GET['p'];
query_posts('p=' . $post_id);
while(have_posts())
{
$this_page = the_post();
echo the_content();
}
?>
It should only display post with one id which is stored in $post_id variable, but for some reason it is getting all of them ;/
not sure if this is what you are looking for, but I understand that you want to display a specific page on your single.php
why not use this:
and add this to your functions.php
/* get page by slug */
Have you tried grabbing the post ID from the URL?
Alternatively, this also might work:
The ugly way:
(
query_posts
alters the main query)The less ugly way: