Good day, tell me why it does not work <? Php the_content (); ?> in single.php, it’s just written, it should work without the_loop loop in this file, but it doesn’t work. But it works <? Php the_title (); ?>, it easily displays the name of the post. Here is the code for single.php:

<!DOCTYPE html> <?php get_header(); ?> <body> <div class="wrapper"> <div class="content-wrap"> <!-- --><div class="sidebar" > <?php wp_nav_menu('menu=main_menu'); ?></div><!-- --><div class="main"> <div class="box"> <h3> <a href="" class="post_url"><?php the_title(); ?></a> </h3> <?php the_content(); ?> </div> </div><!-- </body> </html> 
  • I just can't see the code here, just the markup - Gedweb


2 answers 2

You must first get the content, as in the usual loop:

 <?php if (have_posts()) : while (have_posts()) : ?> <?php the_content(); ?> <?php endwhile; endif; ?> 

    Add the_post(); to the begining

     <?php the_post(); the_content(); ?> 
    • Please try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky