The Time Saving Copy/Paste WordPress Cheat Sheet

December 17, 2015

WP Cheat Sheet

Use this WordPress Cheat Sheet page for a quick, categorized list of WordPress functions.

These are commonly used when building, updating and maintaining templates. Simple, Easy, Copy-Paste. The quick guide to common WordPress > Template functions.

Wordpress Cheat Sheet JPG

Basic Template Files

File Name Description
style.css style sheet file
index.php home page file
header.php header content file
single.php single post page file
archive.php archive/category file
searchform.php search form file
search.php search content file
404.php error page file
comments.php comments template file
footer.php footer content file
sidebar.php sidebar content file
page.php single page file
front-page.php latest posts or static page
tag.php display tags in archive format
category.php display categories in archive format

Header Functions

Function Description
<?php site_url(); ?> root url for website
<?php wp_title(); ?> title of specific post/page
<?php bloginfo('name'); ?> title of site
<?php bloginfo('description'); ?> site description
<?php get_stylesheet_directory(); ?> stylesheet folder location
<?php bloginfo('stylesheet_url'); ?> style.css file location
<?php bloginfo('pingback_url'); ?> pingback url
<?php bloginfo('template_url'); ?> template folder path
<?php bloginfo('version'); ?> wordpress blog version
<?php bloginfo('atom_url'); ?> atom url
<?php bloginfo('rss2_url'); ?> rss2 url
<?php bloginfo('url'); ?> root url for website
<?php bloginfo('html_type'); ?> html version
<?php bloginfo('charset'); ?> charset parameter

Navigation Menu

Default Navigation Menu
<?php wp_nav_menu(); ?>
Specific Navigation Menu
<?php wp_nav_menu( array('menu' => 'Project Nav' )); ?>
Category Based Navigation
<ul id="menu">
<li <?php if(is_home()) { ?> class="current-cat" <?php } ?>>
<a href="<?php bloginfo('home'); ?>">Home</a></li>
<?php wp_list_categories('title_li=&orderby=id');?>
Page Based Navigation
<ul id="menu">
<li <?php if(is_home()) { ?> class="current-page-item" <?php } ?>>
<a href="<?php bloginfo('home'); ?>">Home</a></li>
<?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>

Template Functions

Function Description
<?php the_content(); ?> content of posts/pages
<?php if(have_posts()): ?> check if there are posts
<?php while(have_posts()): the_post(); ?> shows posts
<?php endwhile; ?> closes loop
<?php endif; ?> closes if
<?php get_header(); ?> header.php file contents
<?php get_sidebar(); ?> sidebar.php file contents
<?php get_footer(); ?> footer.php file contents
<?php the_time('m-d-y'); ?> the date is ’08-18-07′
<?php comments_popup_link(); ?> link to comments of post
<?php the_title(); ?> title of post/page
<?php the_permalink(); ?> url of post/page
<?php the_category(); ?> category of post/page
<?php the_author(); ?> author of post/page
<?php the_ID(); ?> id of post/page
<?php edit_post_link(); ?> edit link of post/page
<?php wp_list_bookmarks(); ?> links from blogroll
<?php comments_template(); ?> comment.php file contents
<?php wp_list_pages(); ?> list all pages
<?php wp_list_categories(); ?> list all categories
<?php next_post_link('%link'); ?> url to next post
<?php previous_post_list('%link'); ?> url to previous post
<?php get_calendar(); ?> show post calendar
<?php wp_get_archives(); ?> list of archive urls
<?php posts_nav_link(); ?> next and previous post link
<?php rewind_posts(); ?> rewinds post for a second loop

The Loop

Basic Loop
<?php if(have_posts()) { ?>
<?php while(have_posts()) { ?>
<?php the_post(); ?>
<?php // custom post content code for title, excerpt and featured image ?>
<?php } // end while ?>
<?php } // end if ?>

Extra Functions

Function Description
/%postname%/ custom permalinks
<?php include(TEMPLATEPATH . '/x'); ?> include file from template folder
<?php the_search_query(); ?> value returned from search from
<?php _e('Message'); ?> return translated text from translate()
<?php wp_register(); ?> register link
<?php wp_loginout(); ?> login/logout link
<!--nextpage--> divide content into pages
<!--more--> cut off content and create link to full post
<?php wp_meta(); ?> admin meta data
<?php timer_start(); ?> start page timer (header.php)
<?php timer_stop(1); ?> time to load the page (footer.php)
<?php echo get_num_queries(); ?> show queries executed to generate page


Leave a Reply

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

  1. Ariel says:    •   7 years

    If I had this a year ago, life would be much better 🙁
    Glad to have it now anyhow 🙂

    1. Matthew Loomis says:    •   7 years Author

      I know what you mean, Ariel.

      If I had WordPress eight years ago, life would be much better. 🙂

      WordPress just keeps getting better.

  2. Jez says:    •   6 years

    This is great stuff, thanks for putting it together.

    1. Matthew Loomis says:    •   6 years Author

      Jez, I’m glad you find this helpful. 🙂

  3. Candra says:    •   6 years

    You’re so awesome! I do not think I’ve read through something like that before.
    So good to find somebody with some unique thoughts on this topic.
    Really.. thank you for starting this up. This web site is one thing that is needed on the internet, someone with a bit of

  4. Shahrukh Khan says:    •   6 years

    This is an amazing set of WordPress cheat sheet, Sometimes back I wanted to do the same but due to some other work cant do it. Glad I found this stuff. I wont have to look for these in my older project files for reference. Great work Matthew.

    1. Matthew Loomis says:    •   6 years Author

      I’m really happy to hear how helpful this is for you, Shahrukh.

  5. Nazmul Hasan says:    •   6 years

    Its really save my time, thank you Matthew Loomis!

    1. Matthew Loomis says:    •   6 years Author

      You’re welcome, Nazmul! Glad you like it. 😀

  6. Alexander Reynolds says:    •   6 years

    Yo this was so helpful! Saved my ass!

    1. Matthew Loomis says:    •   6 years Author

      Yo Alexander, happy to hear your derriere was saved.

  7. dfahad says:    •   6 years

    Its very helpful for me. Thanx…

  8. Sandesh Satyal says:    •   6 years

    Man you are awesome…..keep up the good work…..thank you……

  9. Narendra Pratap says:    •   5 years

    Really thanks

  10. elporfirio says:    •   5 years

    Excellent, this is very usefull 😀 now coding like Santa Gnome in Chrismas

  11. Arshad says:    •   5 years

    I don’t get it… what is this ? Matthew ? do I as blogger really need these things.. I never used anything like that in my blogging… crazy html..

    1. Matthew Loomis says:    •   5 years Author

      Hi Arshad,

      Some folks like to do the development of their site themselves. This is for advanced folks who know and enjoy WP development. You can hire someone to do this for you, or just stick with the simple WP setup and design.

      You don’t need this to blog. Only if you want to do more website development on your own.



      1. Arshad says:    •   5 years

        Thank you so much! for replying back Matthew! 🙂

  12. MUNTASIR says:    •   5 years

    Very much thanks for sharing this.

  13. Showhan Ahmed says:    •   5 years

    Nice Tutorials. Thanks

  14. Keva Silvia says:    •   5 years

    Timely blog post – Coincidentally if others want a Copyright PTO/SB/16 , my business used a template form here [link redacted]

  15. Sultan says:    •   5 years

    Thank you sir for this kind of help…………

  16. shemul says:    •   4 years

    Awesome tutorial.It is helpful. Thank you 🙂

  17. Ming Liu says:    •   4 years

    Thanks, friends, it helps a lot