- wp_head():
- Function: Invokes the HTML head element for scripts, styles, and meta tags.
- Explanation: Used to include additional resources, such as CSS stylesheets and JavaScript files, in the
<head>
section of the HTML document.
<?php wp_head(); ?>
- wp_footer():
- Function: Outputs scripts or data before the closing
</body>
tag. - Explanation: Useful for including JavaScript files or scripts at the end of the HTML document for improved page loading performance.
<?php wp_footer(); ?>
- get_header():
- Function: Includes the header.php template file.
- Explanation: Retrieves and displays the site header, typically containing the site title, navigation menu, and other header elements.
<?php get_header(); ?>
- get_footer():
- Function: Includes the footer.php template file.
- Explanation: Retrieves and displays the site footer, usually containing closing HTML tags, scripts, and other footer elements.
<?php get_footer(); ?>
- the_post():
- Function: Sets up the current post in the loop and fetches the post data.
- Explanation: Prepares the current post for display, making post-related functions like
the_title()
, the_content()
, and the_permalink()
available.
<?php while (have_posts()) : the_post(); ?>
- the_title():
- Function: Displays or retrieves the current post title.
- Explanation: Outputs the title of the current post within the loop.
<?php the_title(); ?>
- the_content():
- Function: Displays the content of the current post.
- Explanation: Outputs the main content of the post within the loop.
<?php the_content(); ?>
- the_permalink():
- Function: Displays or retrieves the permalink for the current post.
- Explanation: Outputs the URL of the current post within the loop.
<?php the_permalink(); ?>
- get_sidebar():
- Function: Includes the sidebar.php template file.
- Explanation: Retrieves and displays the site's sidebar content, usually containing widgets, additional navigation, or other supplementary information.
<?php get_sidebar(); ?>
- wp_enqueue_script():
- Function: Enqueues a script for inclusion in a WordPress-generated page.
- Explanation: Adds a script to the queue of scripts to be included on the page, ensuring proper dependency handling and loading order.
wp_enqueue_script('script-handle', get_template_directory_uri() . '/js/script.js', array('jquery'), '1.0', true);