Skip to content

Make your own basic WordPress theme from scratch: Part 2

Read Make your own basic WordPress theme from scratch: Part 1.

Starting from where we left off in Part 1, you should now have the most basic WordPress template working showing a selection of your posts on the first page. First we’re going to make a few changes to our post query loop.

Instead of showing the entire post’s contents on the first page, we only want to show the excerpt. The excerpt can be used as an optional summary or description of a post but you can use it however you like. To edit your post’s excerpt you may have to select it from the Screen Options menu inside the Edit Post page from your site’s administrative portal.

We will also be turning our post’s title into a link to its own page. Take a look at Part 1 if you’d like to review changes or know more about what’s going on in the following code.

To allow for individual posts to have their own page, we will need to create a file called single.php in our template’s directory. This page will be used to display all single posts on their own page. Using the the_permalink() function within ‘The Loop’ will always take us to this page and dynamically generate the content from the post from which the URL was derived.

The following code is a simple single.php page showing the post’s title and content.

About Canadian Web Hosting

Since 1998, Canadian Web Hosting has been providing on-demand hosting solutions that include Shared HostingVirtual Private Servers (VPS), Cloud HostingDedicated Servers, and Infrastructure as a Service (IaaS) for Canadian companies of all sizes. Canadian Web Hosting is SSAE 16 Type II SOC 2 certified, ensuring that their processes and business practices are thoroughly audited against industry standards. Canadian Web Hosting guarantees a 100% network uptime, and a total money-back guarantee that backs everything they do. Customers can get help by calling 1-888-821-7888 to get 24/7 support. For more information, visit them at www.canadianwebhosting.com, or get the latest news by following them on Twitter at @cawebhosting.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *