Table of Contents
1. Give a Complete Path of images and files
<?php echo get_template_directory_uri();?>/
2. Call Header & Footer Files
<?php get_header(); ?>
<?php get_footer(); ?>
3. Reg. Menus for Website & WordPress Dashboard
i. To Reg. WordPress Menu
To register a navigation menu in WordPress these two functions should be used:
register_nav_menus()
Add below code in function file to display menu option in WordPress Dashboard.
<?phpregister_nav_menus(array(‘primary-menu’=>’Header Meanu’))?>
ii. To Reg. Website Menu
For the navigation menu, you have to do two tasks, and you will have to bring it to work on both sides, to bring it on the admin part, and to show it on the website.
wp_nav_menu()
Add the below code in the header file to display menus on the website
<?php
wp_nav_menu(
array(‘theme_location’=>’primary-menu’,’menu_class’=>’nav navbar-nav’)
)
?>
4. Display Pages Title and Content
Note: By Default index.php loads on the website domain. But when we click on any Nav Link it loads the page.php file.
4. How to Display Feature Image
add_theme_support(‘post-thumbnails’);
Add this function in the functions.php file that will enable the featured image option in the WordPress dashboard.
the_post_thumbnail();
Add this function in the page.php file that will display the featured image option on the website. You can get a thumbnail image with a tag and also get an idea about the image path. You can change the parameter in a thumbnail image and set the resolution as per the requirements.
You can edit the image resolution and get the image path with this function.
Dynamic Logo for Website
You can Add the Header Logo option in Appearance by this function.
add_theme_support(custom-header);
Add Above function in functions.php file.
Add the below function to header.php to display the logo on your website header & Link with Home Page.
<a class=”navbar-brand” href=”<?php echo site_url();?> “><?php $logo = get_header_image(); ?><img src=”<?php echo $logo; ?>” alt=”logo” /></a>
Create a New Template
<?php//Template Name:Contact usget_header();?>