WordPress is the most popular blogging platform which let you to create a great looking blog or website in a minutes. Also you can easily enhance your site functionality using WordPress themes and plugins. But still you may need to tackle with the coding of your website. There are many codes to modify your WordPress theme, it helps to have a mini cheat sheet if you are looking to make some small changes or developing your own WordPress theme. In this article we have listed a few useful WordPress Theme Cheat code that you can probably used for editing or customize themes. So, let’s go and Don’t forget to bookmark this page.
Some Basic Theme Files
Here is the list of basic template files that basically used in every themes.
[list style=”file”]
[li]header.php[/li]
[li]index.php[/li]
[li]sidebar.php[/li]
[li]footer.php[/li]
[li]single.php[/li]
[li]page.php[/li]
[li]comments.php[/li]
[li]404.php[/li]
[li]functions.php[/li]
[li]archive.php[/li]
[li]searchform.php[/li]
[li]search.php[/li]
[li]style.css[/li]
[/list]
Beginning: CSS-file (theme details)
This is the general CSS commented code which is used to add your theme details like theme name, URI, theme description, author name etc. You can add this code at top of your “style.css” file. Just double click on it copy and paste. 🙂
/*
Theme Name: Your Theme Name
Theme URI: https://wpdune.com/
Description: Best Premium WordPress Theme.
Author: exploretheme
Author URI: https://wpdune.com/
Version: 1.0
Tags: tag1, tag2, black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats
License:
License URI:
General comments (optional).
*/
Loading jQuery File
Easily add jQuery (.js) file into your theme by adding this bit of code in “header.php” file.
<?php
/* Note : Call this before `wp_head` */
wp_enqueue_script('jquery');
?>
<!-- Add custom JavaScript from theme directory -->
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/custom-javascript.js"></script>
Basic Codes in Header.php
You can seen these codes mostly in header.php although some of these might be seen throughout your theme files. Codes like Location of website’s theme Files are used to call for image URLs all over the template, same goes with the exact url of the site code.
<?php bloginfo(‘name’); ?> – Title of the Blog, or Blog Name
<?php wp_title(); ?> – Title of a Specific Page
<?php bloginfo(‘url’); ?> – Exact URL for the Site
<?php bloginfo(‘description’); ?> – Site’s Description
<?php bloginfo(‘template_url’); ?> – Location of Site’s Theme File
<?php bloginfo(‘stylesheet_url’); ?> – Link to the Style.css location
<?php bloginfo(‘rss2_url’); ?> – RSS Feed URL for the Site
<?php bloginfo(‘pingback_url’); ?> – Pingback URL for the site
<?php bloginfo(‘version’); ?> – WordPress Version Number
Codes for Other Template Files
This is most common codes you will be seen it across all the template files like index.php, single.php, page.php etc. Its really easy to call on these codes to make your theme dynamic when coding it.
<?php get_header(); ?> – Displays Header.php file content
<?php get_footer(); ?> – Displays Footer.php file content
<?php get_sidebar(); ?> – Displays Sidebar.php file content
<?php next_post_link(‘ %link ‘) ?> – URL of the Next Page
<?php previous_post_link(‘%link’) ?> – URL of the Previous Page
<?php comments_template(); ?> – Displays Comment.php file content
<?php the_content(); ?> – Displays the Content of the Post
<?php the_excerpt(); ?> – Displays the excerpt that is used in Posts
<?php the_title(); ?> – Title of the Specific Post
<?php the_permalink() ?> – Link of the Specific Post
<?php the_category(‘, ‘) ?> – Category of a Specific Post
<?php the_author(); ?> – Author of the Specific Post
<?php the_ID(); ?> – ID of a Specific Post
<?php edit_post_link(); ?> – Edit link for a Post
<?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 Users
I Hope this has helped you more. Please gives your reviews in comment section below and spread it around by sharing it with your friends.