Useful WordPress theme snippets

Posted on 7th June, 2013 141 Comments

This is an ever growing, evolving list of useful WordPress snippets, created as a reference for theme developers and hobbyists.
I suggest you drag this link to your favorites and bookmark this page, then simply copy & paste each snip as it’s needed then add it to your theme file. If you’d like to add to the list then add them to your comments below.

Header Snippets

<?php bloginfo('name');?> #Site Title

<?php wp_title();?> #Page or post title

<?php bloginfo('stylesheet_url');?> #stylesheet url

<?php bloginfo('pingback_url');?> #pingback url of your site

<?php bloginfo('template_url');?> #Location of the site template file

<?php bloginfo('version');?> #WordPress version

<?php bloginfo('atom_url');?> #Atom url for the site

<?php bloginfo('rss2_url');?> #RSS url for the site

<?php bloginfo('html_type');?> #Html version of the site

<?php bloginfo('charset');?> #Charset papameter of the site

Theme Snippets

<?php the_author();?> #Author of a specific post or page

<?php the_ID();?> #ID of a specific post or page

<?php edit_post_link();?> #Edit link for a post or page

<?php get_links_list();?> #Links from the blogroll

<?php wp_get_archives();?> #List of archives

<?php comments_template();?> #Comments file content

<?php wp_list_pages();?> #List sites pages

<?php wp_list_cats();?> #List of sites categories

<?php next_post_link('%link');?> #Link to the next post

<?php previous_post_link('%link');?> #Link to the previous post

<?php get_calendar();?> #Show the sites calendar

<?php post_nav_link();?> #Next and previous post link

<?php bloginfo('description');?> #Site Description

<?php the_content();?> #Content of the post

<?php if(have_posts());?> #Checks if there are post

<?php while(have_posts()):the_post();?> #Shows posts if they're available

<?php endwhile;?> #Ends the while

<?php endif;?> #End the if statement

<?php get_header();?> #Get the header.php content

<?php get_sidebar();?> #Get the sidebar.php content

<?php get_footer();?> #Get the footer.php cotent

<?php the_time('d-m-y');?> #Show the date - change the order to suit

<?php comments_popup_link();?> #Link for the comments on the post

<?php the_title();?> #Title of specific post or page

<?php the_permalink();?> #Url of the specific post or page

<?php the_category();?> #category of the specific post or page

Extras

/%category%/%postname%/ #Custom permalinks

<?php bloginfo('url'); ?> #Site url

<?php bloginfo('description'); ?> #Displays the site description

<?php the_post_thumbnail();?> #Displays the post thumbnail

<?php get_bloginfo('template_directory');?> #Location of the site template file

<?php include(TEMPLATE PATH HERE.'/X');?> #Include any file

<?php the_search_query();?> #Value for the search form

<next page> #DIVIDES THE CONTENT INTO PAGES

<more> #CUTS OFF THE CONTENT AND SHOWS READ MORE

<?php wp_meta();?> #Admins meta

CSS

/* Remove the phantom empty paragraph tags from your posts. */
p:empty {
	display:none;
} 

/* Make your posts images responsive */
#content img {
	max-width: 100% !important; 
	max-height: 100% !important;
} 

Comments

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]

industrial construction

13th, Aug, 20

industrial construction

Get in contract here for top quality professional, licensed and bonded industrial construction services that is available to get started on your construction projects and ready to get going with the top quality. Ask for a proposal today!

lymphedema cure

13th, Aug, 20

lymphedema cure

Profit from professional lymphedema treatment centers in houston tx currently taking on new clients and on sale now!

check here

13th, Aug, 20

check here

Buy a plan for expert lymphedema treatment centers houston tx currently taking on new clients in addition on sale now!

cabo honeymoon

14th, Aug, 20

cabo honeymoon

Buy now the best los cabos currently this week available and now in stock and currently available this week only!

check here

14th, Aug, 20

check here

Buy a plan for amazing lymphedema symptoms currently taking on new clients and reasonably priced now!

mechanisms for clocks

14th, Aug, 20

mechanisms for clocks

Find the top deals for clock parts that are available for you and ready to s and plus at a good value for today only!

wedding dj bozeman mt

14th, Aug, 20

wedding dj bozeman mt

Buy a plan for expert joe’s dj service bozeman mt currently taking on new clients in addition reasonably priced now!

browse this site

15th, Aug, 20

browse this site

Get here amazing lymphedema treatment center houston texas currently taking on new clients in addition on sale now!

lymphedema cure

16th, Aug, 20

lymphedema cure

Buy a plan for professional lymphedema clinic houston texas currently open for service in addition reasonably priced now!

cabo villa

16th, Aug, 20

cabo villa

Locate now the top cabo san lucas villas that’s this week available and in stock in addition at the best price this week only!

browse this site

17th, Aug, 20

browse this site

Get here professional lymphedema treatment centers in houston tx currently taking on new clients and reasonably priced now!

original site

17th, Aug, 20

original site

Profit from expert what is lymphedema therapy currently open for service in addition reasonably priced now!

click to read more

17th, Aug, 20

click to read more

Locate the best billing mailing services today on a best offer and gets your business ROI immediately!

Bonuses

17th, Aug, 20

Bonuses

Profit from professional lymphedema causes currently open for service and on sale now!

lymphedema

18th, Aug, 20

lymphedema

Profit from amazing houston texas houston texas currently taking on new clients in addition reasonably priced now!

lymphedema symptoms

18th, Aug, 20

lymphedema symptoms

Profit from expert lymphedema treatment center in houston texas currently open for service and reasonably priced now!

what is lymphedema?

18th, Aug, 20

what is lymphedema?

Buy a plan for amazing lymphedema treatment centers houston tx currently open for service in addition on sale now!

cabo san lucas

18th, Aug, 20

cabo san lucas

Save now a high quality cabo san lucas activities that is this week available and now in stock in addition on sale this week only!

check here

19th, Aug, 20

check here

Buy a plan for amazing lymphangitis currently open for service in addition reasonably priced now!

cabo san lucas

21st, Aug, 20

cabo san lucas

Save now the top cabo san lucas luxury villas currently this week available and in stock in addition at great prices this week only!

lymphedema therapy massage

22nd, Aug, 20

lymphedema therapy massage

Get here professional lymphedema treatment centers houston texas currently open for service in addition reasonably priced now!

lymphedema symptoms

22nd, Aug, 20

lymphedema symptoms

Profit from amazing a blockage in the lymphatic system currently taking on new clients in addition reasonably priced now!

check here

22nd, Aug, 20

check here

Get a top closet remodeling that’s now available in addition at reasonable prices now only!

read this article

23rd, Aug, 20

read this article

Hire the the top closet accessories phoenix that is now available in addition at good rates now only!

seo phoenix

27th, Aug, 20

seo phoenix

Find the the top internet marketing phoenix that’s now available and with reasonably pricing now only!

phoenix az closet

29th, Aug, 20

phoenix az closet

Find the the top closets phoenix az currently now available in addition with reasonably pricing now only!

phoenix closet

29th, Aug, 20

phoenix closet

Get the best closets remodeling phoenix az currently now available and at good rates now only!

closet accessories

30th, Aug, 20

closet accessories

Get the best custom closet phoenix that is now available in addition with reasonably pricing now only!

Bonuses

31st, Aug, 20

Bonuses

Get the the top phoenix closet that’s now available and at reasonable prices now only!

hindu astrology

31st, Aug, 20

hindu astrology

Hire the best hindu astrology currently now available in addition at reasonable prices now only!

metal building kits

31st, Aug, 20

metal building kits

Contract us here for top quality professional, licensed and bonded Industrial Contractors currently available to get started on your construction projects and ready to get going at a top quality. Ask for a proposal today!

Bonuses

31st, Aug, 20

Bonuses

Find the best phoenix closets remodeling that is now available and at good rates now only!

visit

01st, Sep, 20

visit

Get the best decks repair colorado that’s now available in addition at good rates now only!

phoenix closet

02nd, Sep, 20

phoenix closet

Hire a top phoenix az closets organizers that is now available in addition at reasonable prices now only!

page

03rd, Sep, 20

page

Find a top indian astrology currently now available and with reasonably pricing now only!

closets organizers

03rd, Sep, 20

closets organizers

Get the the top check this link right here now that’s now available in addition at good rates now only!

commercial steel buildings

04th, Sep, 20

commercial steel buildings

Get in contract here for a professional, licensed and bonded metal building construction that are available to get started on your construction projects and ready to get going reasonable pricing. Ask for a proposal today!

dig this

05th, Sep, 20

dig this

Get the best phoenix az custom closets currently now available in addition at reasonable prices now only!

commercial metal buildings

06th, Sep, 20

commercial metal buildings

Contact us now for the best professional, licensed and bonded metal church buildings contractor currently available to get started on your construction projects and ready to get going reasonable pricing. Ask for a proposal today!

More hints

06th, Sep, 20

More hints

Get the best online healer that’s now available in addition at good rates now only!

dig this

07th, Sep, 20

dig this

Hire the the top phoenix closets accessories that’s now available and with reasonably pricing now only!

phoenix seo

10th, Sep, 20

phoenix seo

Hire the the top phoenix website design that is now available and on sale now only!

phoenix closet

10th, Sep, 20

phoenix closet

Get the the top custom closet phoenix that’s now available and with reasonably pricing now only!

this

11th, Sep, 20

this

Get the the top thai horoscopes that is now available and on sale now only!

useful reference

11th, Sep, 20

useful reference

Buy a plan for professional montana fishing currently taking on new clients in addition on sale now!

click here now

12th, Sep, 20

click here now

Find the best phoenix az closets accessories that is now available and at good rates now only!

my site

13th, Sep, 20

my site

Find a top original site currently now available in addition at good rates now only!

phoenix closet

14th, Sep, 20

phoenix closet

Find a top phoenix closets accessories that’s now available and at good rates now only!

phoenix closet

15th, Sep, 20

phoenix closet

Find the the top closets remodeling currently now available and at reasonable prices now only!

my site

17th, Sep, 20

my site

Hire a top closets organizers phoenix currently now available in addition with reasonably pricing now only!

construction management

19th, Sep, 20

construction management

Get in contract here for a professional, licensed and bonded metal building erectors that are available to get started on your construction projects and ready to get going reasonable pricing. Ask for a proposal today!

best clock movements

20th, Sep, 20

best clock movements

Buy the top deals for clock parts that’s available for you and for fast deliver and plus at a good value for today only!

message boards for offices

21st, Sep, 20

message boards for offices

Locate now a high quality school bell scheduling systems that are this week available and in stock and on sale this week only!

patio door

22nd, Sep, 20

patio door

Get a top phoenix sliding patio that’s now available and with reasonably pricing now only!

Leave a Comment

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]