Create a custom WordPress theme: Step 2

There are many different WordPress themes available, but sometimes you just cannot find the one that will fit your needs. When that happens, it is time to create your very own custom theme. I will show you in a series of six steps how to do just that.

In step 1 we learned how the themes work, a first step in creating your own custom theme for WordPress. Our second step is to create the template files.

Step 2.                              

The first file we are going to create is the index.php file.

Open up your text editor and create a new file called index.php where you will enter the following code:

<?php get_header(); ?>

<div id="main">

<div id="content">

<h1>Main Content </h1>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<h1><?php the_title(); ?></h1>

<h4>Posted on <?php the_time('F jS, Y') ?></h4>

<p><?php the_content(__('(more...)')); ?></p>

<hr>

<?php endwhile; else: ?>

<p><?php _e('Sorry, we couldn’t find the post you are looking for.'); ?></p>

<?php endif; ?>

</div>

<?php get_sidebar(); ?>

</div>

<div id="delimiter"></div>

<?php get_footer(); ?>

You can make changes between the <h1> tags and the text that reads "Posted on" after the <h4> tag can be customized to something else that works for you. You can make the changes now or at a later time, but it is important to remember that, since these are template files, the changes will be reflected across your entire site.

So, this is second step in creating your own custom theme for WordPress. Stay tuned for step 3 when we'll talk about your header file.

Posted on March 13, 2015 and filed under Custom Wordpress Themes.