Core WordPress functions for template development
Core Structure Functions
-
get_header()– Loads theheader.phptemplate file. -
get_footer()– Loads thefooter.phptemplate file. -
get_sidebar()– Loads a sidebar template (defaultsidebar.php). -
get_template_part()– Includes a reusable template part (like a component). -
wp_head()– Hook for plugins and scripts in<head>section. -
wp_footer()– Hook for plugins and scripts before</body>. -
body_class()– Outputs classes for<body>based on page type. -
post_class()– Outputs classes for<article>or post container.
The Loop Functions
-
have_posts()– Checks if there are posts to loop through. -
the_post()– Sets up post data for use inside the loop. -
the_title()– Displays the current post’s title. -
the_content()– Displays the full content of the post. -
the_excerpt()– Displays a shortened summary of the post. -
the_permalink()– Returns the URL for the current post. -
the_ID()– Outputs the current post’s ID. -
the_post_thumbnail()– Displays the post’s featured image. -
comments_template()– Loads the comments template for the post.
Site & URL Functions
-
bloginfo()– Outputs site info like name, URL, or description. -
get_bloginfo()– Returns site info instead of echoing it. -
home_url()– Returns the home page URL. -
site_url()– Returns WordPress installation URL. -
get_template_directory_uri()– Returns URL of parent theme directory. -
get_stylesheet_directory_uri()– Returns URL of child or current theme directory.
Post Data Functions
-
get_posts()– Fetches an array of posts (simple query). -
wp_reset_postdata()– Resets global post data after a custom loop. -
the_author()– Displays the post author’s name. -
the_date()– Displays the post’s published date. -
the_category()– Displays categories assigned to the post. -
the_tags()– Displays tags assigned to the post. -
get_post_meta()– Retrieves custom field values for a post.