WordPress code snippets – Cheat Sheet

Here is a list of WordPress Code Snippets that can be used in your every day coding phase. If you take a print out of it then it will be the best so that you can keep it your self and distribute among others.

PHP Snippets for Header

Title of the site < ?php bloginfo(’name’); ? >
Title of speci?c post or page < ?php wp_title(); ? >
The style.css ?le’s theme location < ? php bloginfo(’stylesheet__url’); ? >
Pingback URL for the site < ?php bloginfo(‘pingback_url’);? >
Location for the site’s theme ?le < ?php bloginfo(’template_url’);? >
Wordpress version for the site < ?php bloginfo(‘version’);? >
Atom URL for the site < ?php bloiginfo(‘atom_url’);’? >
Exact URL for the site < ?php bloginfo(‘rss2_url’);? >
Name of the site < ?php bloginfo(‘name’);? >
Html version of the site < ?php bloginfo(‘htm1_type’);? >
Charset parameter of the site < ?php bloginfo(‘charset’);? >

Basic Template Files

Style sheet ?le style.css
Homepage ?le index.php
Single post page ?le single.php
Archive/category ?le a1-chive.php
Search form ?le searchform.php
Search content ?le search.php
Error page ?le 404.php
Footer content file footer.php
Comments template ?le comments.php
Header content ?le header-.php
Sidebar content ?le sideba:-.php
Single page ?le page.php

Extra Stuff

Custom permalinks /%postname%/
Include any ?le < ?php include(TEMPLATEPATH .‘/x’); ? >
Value for search form < ?php the_search_query(); ? >
Prints out message < ?php _e(’Message’); ? >
Displays the register link < ?php wp_register(); ? >
Displays the login/logout link < ?php wp_loginout(); ? >
Divides the content into pages
Cuts of” the content <1–more–>
Meta for administrators < ?php wp_meta(); ? >
Time to load the page < ?php timer_stop(1); ? >
Queries to load the page < ?php echo get_num_queries(); ? >

PHP Snippets for Templates

Author of a speci?c post or page < ?php the_author(); ? >
Content of the posts < ?php the_content(); ? > ‘
ID of a speci?c post or page < ?php the_ID(); ? >
Checks if there are posts < ?php if(have_posts()) : ? >
Link to edit a speci?c post or page < ?php edit _post_link(); ? >
Shows posts if posts are available < ?php while(have__posts()) : the _post(); ? >
Links from the blogroll < ?php get_links_list(); ? >
Closes the ‘while’ PHP function < ?php endwhile; ? >
Comment.php ?les content < ?php comments_template(); ? >
Closes the ‘if PHP function < ?php endif; ? >
List of pages of the site < ?php wp_list_pages(); ? >
Header.php ?le’s content < ?php get_header(); ? >
List of categories for the site < ?php wp_list_cats(); ? >
Sidebar.php ?les content < ?php get_sidebar(); ? >
Url to the next post < ?php next _post_link(‘ %link ‘) ? >
Footer.php ?le’s content < ?php get_footer(); ? >
Url to the previous post < ?php previous _post_link(‘%link’) ? >
The date in ’08-18-07′ format < ?php the_time(‘m-d-y’) ? >
The built-in calendar < ?php get_calendar(); ? >
Link for the comments on the post < ?php comments_popup_link(); ? >
List of archives for the site < ?php wp_get_archives() ? >
Title of a speci?c post or page < ?php the_title(); ? >
Next and previous post link < ?php posts_nav_link(); ? >
Url of a specific post or page < ?php the _permalink() ? > ‘
Site’s description < ?php bloginfo(’description’); ? >
Category of a specific post or page < ?php the_category(‘, ‘) ? > ‘

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s