WordPress General Functions

Beginner
6 min read
Updated: Nov 2026
2 examples
Template tags

Definition

General functions are the everyday helpers that a WordPress theme uses on almost every page. They print the site name, load the header, footer, and sidebar, show archive titles, list archives, and build login links.

Popular ones are bloginfo(), get_header(), get_footer(), get_template_part(), and wp_enqueue_script().

Where to use them.

Put them in theme files like header.php, single.php, and archive.php. Functions that add scripts or settings, such as wp_enqueue_script(), belong in functions.php inside a hook.

Syntax

A typical theme template calls several general functions in order:

WordPress
<?php get_header(); ?>

<main>
  <h1><?php bloginfo( 'name' ); ?></h1>
  <?php get_template_part( 'content' ); ?>
</main>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

bloginfo() vs get_bloginfo()

These two are easy to mix up. They take the same values, but one prints and one returns.

FunctionWhat it doesUse it when
bloginfo( 'name' )Prints the value and returns nothing.You want the text on the page right away.
get_bloginfo( 'name' )Returns the value as a string.You want to store it, join it, or escape it first.

Common values are name, description, url, charset, version, and language. Do not write echo bloginfo( 'name' ), because bloginfo() already prints.

Function Groups at a Glance

Pick the group that matches the job, then open the guide you need.

GroupTypical jobStart here
Site infoRead the site name, tagline, URL, version, and page title.bloginfo(), get_bloginfo(), wp_title(), get_current_blog_id()
Template loadingLoad the header, footer, sidebar, reusable parts, and the search form.get_header(), get_footer(), get_sidebar(), get_template_part()
Archive titlesPrint the title of a post, category, tag, term, month, or post type archive.single_post_title(), single_cat_title(), single_tag_title(), single_term_title()
Archives, calendar & linksList archives, build archive links, and show the post calendar.wp_get_archives(), get_archives_link(), get_calendar(), delete_get_calendar_cache()
Auth & meta helpersLogin and logout links, the login form, the Meta list, allowed comment tags, and scripts.wp_login_url(), wp_logout_url(), wp_lostpassword_url(), wp_loginout()

WordPress Examples

Two short theme examples with sample output.

Example 1 — Print vs return

Use bloginfo() to print and get_bloginfo() to return.

WordPress
<h1><?php bloginfo( 'name' ); ?></h1>

<?php
$tagline = get_bloginfo( 'description' );
echo '<p>' . esc_html( $tagline ) . '</p>';
?>

How It Works

  1. bloginfo( 'name' ) prints the site title right away.
  2. get_bloginfo( 'description' ) returns the tagline into a variable.
  3. We escape the variable and print it ourselves.

Example 2 — Build a page from parts

Load the header, a content part, and the footer.

WordPress
<?php
get_header();
get_template_part( 'content', 'single' );
get_sidebar();
get_footer();

How It Works

  1. get_header() loads the top of the page.
  2. get_template_part() loads the post content file.
  3. get_sidebar() and get_footer() finish the page.

Next: WordPress General Functions Index

After you know the basics, open the functions index for all 29 guides.

Full list: WordPress General Functions index (/wordpress/general/function).

Frequently Asked Questions

They are template tags and helpers that most themes use: printing the site name, loading the header, footer, and sidebar, showing archive titles, and building login links.
bloginfo() prints the value. get_bloginfo() returns it so you can store it or join it with other text.
Mostly in theme files such as header.php, footer.php, single.php, and archive.php. Some, like wp_enqueue_script(), go in functions.php on a hook.
Use get_template_part(). For example, get_template_part( 'content', 'single' ) loads content-single.php, or content.php if the first file is missing.
Call wp_enqueue_script() inside a function hooked to wp_enqueue_scripts. Do not add script tags by hand.
Open the WordPress General Functions index. It lists all 29 guides with short descriptions.

Browse every general function

Open the functions index for simple guides with examples and FAQs.

General Functions Index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful