WordPress is fetching current post for you, you have to only type to the right url. When you get e.g. to example.com/lorem-ipsum/
WordPress will load automatically post with title Lorem ipsum
and display it using page.phppage.php
template. Your page.phppage.php
template should be looking something like that.
<?php get_header(); ?>
<div id="content">
<?php while ( have_posts() ) : the_post(): ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
// If comments are open or we have at least one comment, load up the comment template.
<?php if ( comments_open() || get_comments_number() ) : ?>
<?php comments_template(); ?>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php
get_sidebar();
get_footer();
KeyThe concept which beginners do notof a loop is difficult to understand arefor novice developers. Only in the loop you can use functions like loopsthe_title
or the_content
. Outside of the loop
, these functions won't return you anything.