The name Cheat Sheet might be misleading in this case but this is what is used for this stuff generally. It is actually the list of common files, snippets, functions, variable etc used in WordPress structure. With this list, you will get a good overview of the WordPress code structure and will find it easy to customize WordPress themes and plugins.
What is CheatSheet?
Cheatsheet is usually referred to as a set of instructions/information about the internal structure of a software. Once you know the internal structure of a software you will be able to understand and customize it completely. As you may understand that only open source software comes with a cheat sheet on their own. Any licensed software will never bring up its own cheatsheet. So people try to get into that software going out of the way and bring up the information which is called cheatsheet as it is a cheating in itself when we see it with respect to a licensed software. But when we talk about an opensource software it doesn’t amount to any unethical practice as its developer allows us to use it any way we wish to. Still, the name carries. So though it is not wrong to understand WordPress’ internal structure and modify it. Hope now you are ok with the phrase Cheatsheet.
How is CheatSheet Useful for WordPress?
As we discussed that Cheatsheet provides information about the internal code structure of WordPress. You get to know about all the basic functions and snippets used in WordPress code which make it easy for you to work with the WordPress website. Let’s understand it with an example – If you need to put the register page link at some place on your WordPress website. It seems to be a difficult task as you might need to find the link to this page in the WordPress code. But if you go through the Cheatsheet you will find a function wp_register(); . This can be used to display the register link anywhere on the website.
By the above example, you would have understood how important the understanding of cheatsheet is.
Common Cheat Sheets on WordPress
Here are some commonly used cheatsheets for WordPress :
TEMPLATE FILES | |
---|---|
index.php | File for Initialization of WordPress Instance |
single.php | File for Single Post structure |
archive.php | File for Category / Archive page structure |
searchform.php | File for Search Form structure |
search.php | File for Search Content Display structure |
style.css | Base Stylesheet file |
sidebar.php | Sidebar structure file |
comments.php | Comment format file |
404.php | Page Not Found error file |
header.php | Header structure file |
page.php | File for Single Post structure |
PHP FUNCTIONS IN HEADER.PHP | |
---|---|
bloginfo(‘name’); | To display site title |
wp_title(); | To display title of specific post or page |
get_stylesheet_directory_uri(); | Location of style.css file |
bloginfo(‘charset’); | Charset parameter of the site |
bloginfo(‘html_type’); | HTML version for the website |
bloginfo(‘rss2_url’); | RSS2 URL for the site |
bloginfo(‘atom_url’); | Atom URL for the site |
bloginfo(‘version’); | WordPress version used in the site |
bloginfo(‘name’); | Website’s name |
bloginfo(‘template_url’); | Theme’s files URL |
bloginfo(‘pingback_url’); | Site’s pingback URL |
PHP FUNCTIONS FOR TEMPLATES | |
---|---|
the_content(); | Post content |
if(have_posts()): | To check if there is any post |
while(have_posts()): the_post(); | If posts are available show them |
endwhile; | Close while loop |
endif; | Close if block |
edit_post_link(); | URL to edit a page or post |
get_links_list(); | Links from blogroll |
comments_template(); | Content of comment.php file |
posts_nav_link(); | Next and Previous post link |
get_header(); | Get the header content from header.php file |
get_sidebar(); | Get the sidebar content from sidebar.php file |
get_footer(); | Get the footer content from footer.php file |
wp_list_pages(); | List of pages |
wp_list_cats(); | List of categories |
bloginfo(‘description’); | Description of site |
the_time(‘m-d-y’); | Date in Month, Date, Year format |
next_post_link(‘%link’); | Link to the next post |
previoust_post_link(‘%link’); | Link to the previous post |
get_calendar()’ | Built in calender |
wp_get_archives(); | Archives list |
comments_popup_link(); | Link for the comments on the post |
the_title()’; | Specific post or page title |
the_permalink(); | Link URL for specific post or page |
the_category(); | Holds category of specific post or page |
the_author(); | Author of the post or page |
MISCELLANEOUS | |
---|---|
/%postname%/ | Customized permalinks |
include(TEMPATEPATH . ‘/x’); | Include an external file file |
the_search_query(); | Value for the search form |
_e(‘Message’); | Prints out message |
wp_register(); | Display the register link |
wp_loginout(); | Display the login/logout link |
wp_meta(); | Meta for administrators |
echo get_num_queries(); | Queries to load the page |
Divides the content into pages | |
timer_stop(1); | Time to load the page |
Cuts off the content and adds a read more link |