Unlock the Secrets of WordPress Themes: A Beginner's Cheat Sheet
WordPress is the most popular Content Management System (CMS) used by number of developers. Most of the websites are built using WordPress. WordPress is an open source CMS written in PHP. WordPress contain number of themes and plugins which can be used to enhance the functionality of the website. Themes changes the look of your website. A theme contain a number of files which are used to perform various functions. Each theme have some common template files which we will discuss in this article.
Basic Template Files
These are the basic files that every theme contain:
style.css – This is the Stylesheet of your website used to style the website look.
index.php – This is the core file of your theme. It brings all the information of other theme files using tags or hooks.
header.php – This file contains all the information which contain by head section like link to stylesheets and metadata.
sidebar.php – This file contain information of sidebar like widgets, categories, search forms, categories and much more.
footer.php – This file contains all the information of footer like widgets, social icons, copyright and link to scripts.
single.php – This file is used to display single post.
page.php – This file is responsible when you create a page.
comments.php – This file is used to display comments.
404.php – This is the error page. If visitor visits a page that doesn’t exist, then this file will load.
functions.php – This file is used to create special functions.
archive.php – This is the archive or category file.
search.php – Allows to search your website with this page.
searchform.php – This file is used to display a search form.
Template header tags
This are the tags which are contained by header.php file.
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php bloginfo('name'); ?> – Title of the Blog.
<?php bloginfo('url'); ?> – URL of your website.
<?php bloginfo('stylesheet_url'); ?> – Load your theme stylesheet.
<?php bloginfo('template_url'); ?> – Theme file location.
<?php bloginfo('description'); ?> – Displays the tagline of your website.
<?php bloginfo('atom_url'); ?> – Link to your site’s atom URL
<?php bloginfo('rss2_url'); ?> – RSS feed URL for your website
<?php bloginfo('pingback_url'); ?> – Pingback URL for your website
<?php bloginfo('version'); ?> – Version number of WordPress
<?php bloginfo('html_type'); ?> – HTML version your site
<?php site_url(); ?> – Website root URL
<?php get_stylesheet_directory(); ?> – Stylesheet folder location
<?php wp_title(); ?> – Specific Page Title
Template Include Tags
This are the hooks which are used to load the different template files.
1
2
3
4
<?php get_header(); ?> – Load the header.php file
<?php get_sidebar(); ?> – Load the sidebar.php file
<?php get_footer(); ?> – Load the footer.php file
<?php comments_template(); ?> – Load your comments
Template Tags
These are the additional tags used by every template files to display specific information anywhere on your website.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php the_content(); ?> – Displays the main content of a post
<?php the_excerpt(); ?> – Displays the excerpt used in your posts
<?php the_title(); ?> – Title of the specific post
<?php the_permalink() ?> – Link of a specific post
<?php the_category(', ') ?> – Category of a specific post
<?php the_author(); ?> – Author of a specific post
<?php the_ID(); ?> – ID of a specific post
<?php edit_post_link(); ?> – Edit link for a post
<?php next_post_link(' %link ') ?> – URL of the next page
<?php previous_post_link('%link') ?> – URL of the previous page
<?php get_links_list(); ?> – Lists all links in blogroll
<?php wp_list_pages(); ?> – Lists all pages
<?php wp_get_archives() ?> – List archive for the site
<?php wp_list_cats(); ?> – Lists all categories
<?php get_calendar(); ?> – Displays the built-in calendar
<?php wp_register(); ?> – Displays register link
<?php wp_loginout(); ?> – Displays login/logout link only to registered
We hope you like this article. If you have any query, you can ask in below comment box.
You can also check How to create custom post types in WordPress.