Function Name |
Description |
Header and Footer Function |
get header (); get footer(); |
These functions import the content of header.php and footer.php |
wp_head (); |
It is a hook that allows WordPress to add HTML, scripts and stylesheets in the <head> tags of your theme. Used in header.php |
wp_footer(); |
To load java script files at closing body. Used in footer.php |
Blog Function |
have_posts() |
For total number of post |
the_post() |
For each post to display with information |
the_title() |
Title for each post |
The_archive_title |
Display the archive title based on the queried object. |
the_content() |
Body Content for each post |
the_permalink() |
To give link on anything |
Get_post_type_archive_link(‘’) |
To get link of archive page |
site_url () |
Site_url() for index or home page or use Site_url(‘/about-us’) for particular page |
date (‘m -F-Y’) get_the_date() |
To get the published post Date |
the_author() |
To get the Author Name |
get_comments_number() |
To get the Number of Comments |
the_excerpt() |
Display the post excerpt and the default length is 55 words. Similar to content but for small info. |
Paginate_links() |
For pagination |
Get_field |
Get the field in case of custom filed plugin |
Menu Function |
register_nav_menu(‘any Name’, ’Human Friendly Name’) |
Registers a navigation menu location for a theme. |
Wp_nav_menu() |
Displays a navigation menu. |
Widget Function |
register_sidebar() |
WordPress function to register the widget |
dynamic_sidebar() |
WordPress function to call the widget |
Get Image Functions |
get_theme_file_uri() |
WordPress function to give path of an image e.g. get_theme_file_uri(‘/img/logo.png’) <?php get_template_directory_uri(); ?>/logo.png |
get_template_directory_uri() |
get_the_post_thumbnail_url(); |
To get the featured images of the post |
Short Code Function |
do_shortcode(‘[]’) |
WordPress function to use shortcode of any plugin |
Hooks Function |
wp_enqueue_style(‘name’,location) |
Registers the script and enqueues it |
wp_enqueue_scripts(‘name’, url, dependency, version, load before closing) |
Fires when scripts and styles are enqueued. wp_enqueue_script(‘scriptname’, get_template_directory_uri() . ‘/js/scriptsbundled.js’, array(), null, true); in place of version use microtime() |
get_stylesheet_uri() |
The stylesheet file name is ‘style.css’ which is appended to the stylesheet directory URI path |
add_action() |
Actions are the hooks that the WordPress launches at specific points during execution, or when specific events occur. |
add_theme_support |
Registers theme support for a given feature. Like title, custom Logo etc |
after_setup_theme |
This hook is called during each page load, after the theme is initialized. It is here used for title menu .registration |
get_the_ID() |
Retrieve the ID of the current item in the WordPress Loop. |
wp_get_post_parent_id() |
Returns the ID of the post’s parent page. |
wp_get_post_parent_id(get_the_ID()) |
Display only if current page is child Page and 0 of parent page then false <?php If(wp_get_post_parent_id(get_the_ID())){ ?><?php}?> |
wp_list_pages() |
wp_list_pages() generates a nested, unordered list of WordPress pages |
Get_pages() |
wp_list_pages() handled the output of the pages on the screen for us and Get_pages() returns the pages in the memory otherwise both are similar |
Is_page(‘name’) |
Determines whether the query is for an existing single page. Current page is given name page |