Podcast Episode

457 – Creating a WordPress Theme out of HTML – Part 2

Announcements

Is there a plugin for that?

With more than 50,000 plugins in the WordPress repository, it’s hard to find the perfect one. Each week, I will highlight an interesting plugin form the repository.

For more great plugins, download my 50 Most Useful Plugins eBook.

Easy Floating Video allows you to play your videos hosted on YouTube or Vimeo when you scroll down on a page.

Creating a WordPress Theme out of HTML – Part 2

Last week we focused on getting the home page to look like you’d like it to, by modifying the index.php file.

Now, it’s time to make it more “WordPress-y”

Create a Page

This is where the knowledge of the loop comes in.

Create page.php and use the following to create a header for the page:


<?php
/*
Template Name: My-New-Page-Template
*/
get_header(); ?>

This file needs to be saved in wp-content/themes/nameoftheme

Reserved file names:
https://www.ostraining.com/blog/wordpress/custom-page-template-wordpress/

Here’s a sample:


<?php /* Template Name: CustomPageT1 */ ?>
 
<?php get_header(); ?>
 
<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">
        <?php
        // Start the loop.
        while ( have_posts() ) : the_post();
 
            // Include the page content template.
            get_template_part( 'template-parts/content', 'page' );
 
            // If comments are open or we have at least one comment, load up the comment template.
            if ( comments_open() || get_comments_number() ) {
                comments_template();
            }
 
            // End of the loop.
        endwhile;
        ?>
 
    </main><!-- .site-main -->
 
    <?php get_sidebar( 'content-bottom' ); ?>
 
</div><!-- .content-area -->
 
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Next step, determine what other pages need to have custom templates. This in where you can define sidebars, different backgrounds, etc.

Determine what items on the home page can be edited in WordPress

If your site has a header, then you might not want that editable.

All the creation happens in the index.php file

Add plugins

Time to add the necessary plugins. If it’s an eCommerce site, products need to be added, etc.

All plugins need to be tested to make sure they are working.

Thank You!

Thank you to those who use my affiliate links. As you know I make a small commission when someone uses my link and I want to say thank you to the following people. For all my recommended resources, go to my Resources Page