Monday, June 29, 2015

A Minimally Useful Theme

Now we are going to make the theme minimally useful by updating the index.php and the style.css files.

index.js
<html>
  <head>
    <title>Barebones</title>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
  </head>
  <body>
    <?php while (have_posts()) : the_post(); ?>
      <?php the_content(); ?>
    <?php endwhile; ?>
  </body>
</html>

style.css
body {
  background-color: yellow;
}

The first thing one will notice is that the stylesheet is now being applied (however hideous).  In order to see the posts (actually can be either posts or pages) showing on the screen, we need to add some content.  Since we are focused on creating a home page and a hierarchy of sub pages, we will create the following pages with some random content, e.g., "hello from page A", etc.
  • home
  • A
  • B
note: We will treat pages A and B as top level pages instead of setting home as their parent to give us clean URLs later.

When viewing a page, i.e., selecting view from admin,  one will now see the content displayed on the screen.

Finally, we will go ahead and set the home page to load as what loads when the site is loaded without any query string (i.e., the home page of the site). Use admin > settings > reading > Front page displays to set this.

No comments:

Post a Comment