Setting global Header and Footer in Wordpress

 In theme file create header.php and footer.php

and in index.php use header and footer like below code ->

<?php get_header();  

while(have_posts()) {
   the_post(); ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title();  ?></a></h2>
<?php the_content();  ?>
<hr>
<?php } ?>

<?php get_footer();  ?>

and save. and also thease function for header and footer in single.php and page.php


Now add below html code in header.php file 

<!DOCTYPE html>
<html>

<head>
  <?php wp_head(); ?>
</head>

<body>
  <h1>Fictional University</h1>
</body>

</html>

and save it.

now create functions.php file to add new method for load css file and js file

and add below code to load css file dynamic ->

function university_files() {
  wp_enqueue_style('university_main_styles', get_stylesheet_uri());
}
add_action("wp_enqueue_scripts", "university_files");

and save and check blog text clor changed.

also from header.php remove closing body and html and put that in footer.

<?php wp_footer();  ?>
</body>

</html>

Comments

Popular posts from this blog

Basics Of PHP

Creating App.js for Node Application

WordPress Full Guide For Developer