WordPress Theme: Article Page

Article page code is a combination of HTML page code and several components originally provided by Wordpress.

Page structure

We will break it into two parts. First, the global structure of the article page, which is placed in the single.php file.

Global page

<html>
<head></head>
<body>

<?php get_header(); ?>

<?php the_post() ?>
<div class="singlepost">
         <h1 class="postitle"><?php the_title(); ?></h1>
         <div class="content">
                <?php the_content(); ?>
          </div>
</div>

<?php get_sidebar() ?>

<?php get_footer(); ?>

</body>
</html>

Calling the the_post () function retrieves the contents of the last post, but it is the_content () that displays the text and the_tile () header that are contained in fields other than the database.

The same page also contains other files corresponding to the header, footer, sidebars.

In practice, page codes such as <html>, <head>, <body> are placed rather in the header.php file to be reused on the home page (unless you want them to be different). So get_header () is enough to integrate them.
Similarly, </body> and </html> are placed in the footer.php file.

Article Body Details

Now you can see how the various components provide information about the article that is considered useful to readers .

<?php the_post() ?>
<h1 class="postitle"><?php the_title(); ?></h1>
<?php
  the_category(', ') ;
  the_content();
  edit_post_link();
  wp_link_pages(); 
  if (comments_open())  comments_template();
?>

The order of the elements is at the discretion of the author of the topic, and when at the presentation it completely depends on the style sheet .
Components are an edit button: edit_post_link (), links on the next and previous pages: link_pages () and a block of comments.
To change the appearance of each element using a style sheet, you must also assign classes:

<?php the_post() ?>
<h1 class="postitle"><?php the_title(); ?></h1>
<div class="cat"> <?php  the_category(', ') ; ?></div>
<div class="content"><?php  the_content();  ?></div>
<div class="edit"><?php  edit_post_link(); ?> </div>
<div class="links"><?php  wp_link_pages(); ?> </div>
<div class="comments">
  if (comments_open())  comments_template();
</div>
?>

Our article page is ready to be posted online, it remains to also define a static page (which may be similar to this one, and a home page that displays several tickets or summaries of recent articles.

Other components

The list of recent articles can be viewed after the article, not in the panel.

wp_get_archives('type=postbypost&limit=10'); 

This list is useless on the home page, so the article page is the best place to view it.

Useful documentation

The page can use article components and database access widgets.