Here’s something odd, I want to print out a certain post on any page request, if you have a constant $idnumber of your favorite page/message, then add:
$GLOBALS['post'] = get_post( $idnumber );
the_title();
echos that specific page’s title,
get_permalink();
looks ok too,
but the_content()
actually ignores the post set, and just prints whatever page was requested, again.
3 Answers
There are many globals that are being set in a loop, not only $post
, and you need to set all of them to get exactly the same behavior. To get this it is not enough to set $post
but you also need to use setup_postdata