12 Must-Know WordPress Functions For Theming

This post includes WordPress functions that I find myself using over and over again when creating themes for WordPress. These functions are for the most part basic, but they are very useful and every WordPress developer should know them.

1. wp_head()

Used in header.php, wp_head() triggers the wp_head hook that is pretty much required in order to run a smooth WordPress website. Plugins rely heavily on this function to make references to script files, jQuery libraries, stylesheets, etc. It must be place within the opening and closing head tags.


2. wp_footer()

Similar to wp_head(), wp_footer() is also used to call files required by many plugins. It must be placed right before the closing body tag.


3. bloginfo()

Used to display information about your site, such as site name, description, url, stylesheet url, template url, and more. Example:

4. get_header(), get_footer(), get_sidebar()

Functions used to include the template files header.php, footer.php, and sidebar.php respectively. They are the base of a WordPress template.

Note: You can also use name parameters to these functions in order to call for different template files. This is very handy when the layout of a website changes on different pages. For Example:

The example above would include template files named header-contact.php and footer-contact.php, allowing you to create custom headers and footers without altering your main header.php and footer.php files. It also works with get_sidebar().

5. is_front_page()

This is one of my favorites WordPress functions. It’s used to display something on the home page of a static front page setup under Appearance > Reading. Example:

6. is_home()

Very similar to is_front_page(), is_home is used to display stuff on the home page of a website with “latest posts” front page setup under Appearance > Reading. Example:

7. is_page()

Checks if a specific page or set of pages are being displayed. You can use page id, name, or slugs as parameters, like so:

// Page Name

// Page ID

// Page Slug

// Pages with ID's 45, 60, 72 

// Pages About Us, Contact Us and Testimonials

8. is_single()

Targets the single post view. The page after you click to read a post. It also accepts post id, post title, and slug parameters.

9. is_category()

Checks if a category archive page is being displayed. You can also target specific category pages by using parameters in the function. Those can be Category ID, title, slug or an array of ID’s, names and slugs. For example:

10. is_archive()

Checks if any type of archive page is being displayed

11. wp_list_pages()

Used to display pages as links on your site. You can arguments to display all pages, child pages of a specific page, order the pages, and more. Example:

For a full list of arguments, visit the WordPress codex.

12. wp_list_categories()

Used to display a list of categories as links on your site. Example:


For a full list of arguments, visit the WordPress codex.

Posted in WordPressTagged Leave a comment

Ready to get started?

Get a Free Estimate