You need to use setup_postdata()
.
$post = get_post( $id );
setup_postdata( $post );
if(! empty( $post ) ){
the_title();
echo '<br>';
the_content();
}
else {
echo "No page found matching ID $id";
}
You need to use setup_postdata()
.
$post = get_post( $id );
setup_postdata( $post );
if(! empty( $post ) ){
the_title();
echo '<br>';
the_content();
}
else {
echo "No page found matching ID $id";
}