Core WordPress functions for template development

Lesson#4 of 13 in project Theory
Thumbnail for Core WordPress functions for template development

Core Structure Functions

  1. get_header() – Loads the header.php template file.

  2. get_footer() – Loads the footer.php template file.

  3. get_sidebar() – Loads a sidebar template (default sidebar.php).

  4. get_template_part() – Includes a reusable template part (like a component).

  5. wp_head() – Hook for plugins and scripts in <head> section.

  6. wp_footer() – Hook for plugins and scripts before </body>.

  7. body_class() – Outputs classes for <body> based on page type.

  8. post_class() – Outputs classes for <article> or post container.




The Loop Functions

  1. have_posts() – Checks if there are posts to loop through.

  2. the_post() – Sets up post data for use inside the loop.

  3. the_title() – Displays the current post’s title.

  4. the_content() – Displays the full content of the post.

  5. the_excerpt() – Displays a shortened summary of the post.

  6. the_permalink() – Returns the URL for the current post.

  7. the_ID() – Outputs the current post’s ID.

  8. the_post_thumbnail() – Displays the post’s featured image.

  9. comments_template() – Loads the comments template for the post.




Site & URL Functions

  1. bloginfo() – Outputs site info like name, URL, or description.

  2. get_bloginfo() – Returns site info instead of echoing it.

  3. home_url() – Returns the home page URL.

  4. site_url() – Returns WordPress installation URL.

  5. get_template_directory_uri() – Returns URL of parent theme directory.

  6. get_stylesheet_directory_uri() – Returns URL of child or current theme directory.




Post Data Functions

  1. get_posts() – Fetches an array of posts (simple query).

  2. wp_reset_postdata() – Resets global post data after a custom loop.

  3. the_author() – Displays the post author’s name.

  4. the_date() – Displays the post’s published date.

  5. the_category() – Displays categories assigned to the post.

  6. the_tags() – Displays tags assigned to the post.

  7. get_post_meta() – Retrieves custom field values for a post.