The Most Comprehensive WordPress Cheat Sheet for beginners
The WordPress beginner developers who are still trying their hands on WordPress often try to look up for cheat sheets. In their quest for the most useful one, they come across various cheat sheets. However, they mostly find these cheat sheets insufficient for their purpose. This leads to the search for the most comprehensive cheat sheet – the one-in-all solution!
This year, you no longer need to spend hours in front of the computer screen in order to find the most comprehensive cheat sheet. We are here to your rescue!
The most comprehensive WordPress cheat sheet of 2020 for beginners has been laid out in the text below.
Most widely used WordPress Theme Templates
Each WordPress theme comprises numerous different files which are called templates. Some basic files that are part of every template are:
style.css
header.php
index.php
sidebar.php
footer.php
single.php
page.php
comments.php
404.php
functions.php
archive.php
searchform.php
search.php
If you wish to create your own custom-made theme, then you can start off with one of the WordPress starter themes. Such themes have ready to use WordPress template files and CSS. You can build up more on these two and create a theme according to your own needs and requirements.
However, creating a custom WordPress website from scratch can be daunting. Don’t let this fear hold you back on getting a WordPress website that your business deserves.
Contact us to learn how we can help you with a fully customised WordPress website.
Template tags to be used in header
WordPress is a CMS that has numerous functions. These functions are labelled as template tags. They can be used to output different aspects in your theme.
The most basic yet essential function required in almost all WordPress themes in known as wp_head, and this is what it looks like:
<?php wp_head(); ?>
This code inculcates all basic HTML WordPress requirements to add in the <head> section of your site. It also plays a crucial role in making WordPress plugins work efficiently on your site.
Listed below are the template tags that are commonly found in a theme’s header file:
// Title of the Blog, or Blog Name
<?php bloginfo('name'); ?>
// Title of a Specific Page
<?php wp_title(); ?>
// Exact URL for the site
<?php bloginfo('url'); ?>
// Site’s Description
<?php bloginfo('description'); ?>
// Location of Site’s Theme File
<?php bloginfo('template_url'); ?>
// Link to the Style.css location
<?php bloginfo('stylesheet_url'); ?>
// RSS Feed URL for the site
<?php bloginfo('rss2_url'); ?>
// Pingback URL for the site
<?php bloginfo('pingback_url'); ?>
// WordPress version number
<?php bloginfo('version'); ?>
Template tags used in other theme files
These are the template tags that are used to include other templates:
//Displays Header.php file content
<?php get_header(); ?>
// Displays Footer.php file content
<?php get_footer(); ?>
// Displays Sidebar.php file content
<?php get_sidebar(); ?>
// Displays Comment.php file content
<?php comments_template(); ?>
Following are the template tags that are used inside WordPress to display your posts:
// Displays the Content of the Post
<?php the_content(); ?>
// Displays the excerpt that is used in Posts
<?php the_excerpt(); ?>
// Title of the Specific Post
<?php the_title(); ?>
// Link of the Specific Post
<?php the_permalink() ?>
// Category of a Specific Post
<?php the_category(', ') ?>
// Author of the Specific Post
<?php the_author(); ?>
//ID of a Specific Post
<?php the_ID(); ?>
// Edit link for a Post
// Oonly visible to logged in users with editing privileges
<?php edit_post_link(); ?>
// URL of the next page
<?php next_post_link(' %link ') ?>
// URL of the previous page
<?php previous_post_link('%link') ?>
WordPress themes have widget-ready areas known as Sidebars. These sidebars are basically areas where users can drag and drop widgets. Often, there are multiple side bars.
Widget areas are either in the right or left sidebar of the theme layout.
The code used to display a sidebar is:
<?php
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
return;
}
?>
<aside id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</aside><!-- #secondary →
Template tags that display navigation menus
WordPress is known for its efficient menu management system which helps users in creating navigation menus for their sites. A WordPress theme can either have one or more than one navigation menu location.
The code that will be used to display the navigation menu is as follows:
<?php
wp_nav_menu( array(
'theme_location' => 'my-custom-menu',
'container_class' => 'custom-menu-class' ) );
?>
Template tags that do not fall under any category but are frequently used
Here are a few essential WordPress tags that you will be using frequently while creating your website in WordPress:
// Displays the date current post was written
<?php echo get_the_date(); ?>
// Displays the last time a post was modified
get_the_modified_time
// Displays the last modified time for a post
<?php echo the_modified_time('F d, Y'); ?>
// Displays post thumbnail or featured image
<?php the_post_thumbnail( ); ?>
// Displays monthly archives
<?php wp_get_archives( ); ?>
// Displays the list of categories
<?php wp_list_categories(); ?>
// Displays the gravatar of a user from email address
// 32 pixels is the size, you can change that if you need
<?php echo get_avatar( 'email@example.com', 32 ); ?>
// Displays gravatar of the current post’s author
<?php echo get_avatar( get_the_author_meta( 'ID' ), 32 ); ?>
Conditional tags used in WordPress Themes
Conditional tags are those tags that give you results in true or false. These tags can be used anywhere in your theme, depending on the needs and requirements.
Some of the conditional tags that can be used are:
// Checks if a single post is being displayed
is_single()
// Checks if a page is being displayed
is_page()
// Checks if the main blog page is displayed
is_home()
// Checks if a static front page is displayed
is_front_page()
// Checks if current viewer is logged in
is_user_logged_in()
Apart from these, there are numerous other conditional tags too that can be found on the website of WordPress. But if attempting to add a code to your website yourself scares you, get in touch with our experts and let us customise your theme for you!
The WordPress Loop
The WordPress loop refers to the code which is used to display posts in WordPress. Some of the WordPress template tags only work inside the loop.
One such simple WordPress loop is:
<?php
// checks if there are any posts that match the query
if (have_posts()) :
// If there are posts matching the query then start the loop
while ( have_posts() ) : the_post();
// the code between the while loop will be repeated for each post
?>
<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<p class="date-author">Posted: <?php the_date(); ?> by <?php the_author(); ?></p>
<?php the_content(); ?>
<p class="postmetadata">Filed in: <?php the_category(); ?> | Tagged: <?php the_tags(); ?> | <a href="<?php comments_link(); ?>" title="Leave a comment">Comments</a></p>
<?php
// Stop the loop when all posts are displayed
endwhile;
// If no posts were found
else :
?>
<p>Sorry no posts matched your criteria.</p>
<?php
endif;
?>
Conclusion
We have laid out the most comprehensive WordPress cheat sheet of 2020 for you. It has all the codes that a beginner needs to start off with WordPress.
Still, we find no harm in confessing that even a cheat sheet as comprehensive as this one might not be sufficient to help one get started. After all, dealing with WordPress is not that straight forward. But that’s where we come in. Get in touch with us and let us take your WordPress website customisation up a notch!
If you think it is hard to follow through this cheat sheet, do not worry. We are here to take care of your web development needs. Drop us a line and our team of experts will get back to you!