Is there a way to obtain the data from a certain page outside the regular flow, more efficiently than via get_post($id)
?
I know that I can get for example the title with
$post = get_post($id);
$title = $post->post_title;
But I prefer to use the loop, rather than picking every single page element in the way I described above.
So what I want, is to read the entire page data, and then perform a ‘regular loop’, using the_title()
, the_content()
, the_post_thumbnail()
etc.
The reason why I ask this is because I’m busy creating a ‘404 solution’ for my theme, where one is able to create and edit a custom 404 page in the WordPress backend.
You need to use
setup_postdata()
.