You get a bonus - 1 coin for daily activity. Now you have 1 coin

WORDPRESS 23 Footer. Divide the index into zones.

Lecture




Today we summarize the styling and touch on an important question - how to properly divide the index.php file into several small files. At the beginning of the lesson you will need a style.css file . Next, you will work with index.php , and also create several new files. Probably thinking “well, is it really the final soon?” =) That is, we have almost finished the basic course!

Discover everything you need and start.

Step 1

Add padding: 10px to the footer div tag. Hope you remember how to add padding ? This time, I'm not writing code anymore, hoping for your memory ;-)

Step 2

Assign the height of the 18px string to all <p> footer tags via #footer p {} .

Today we are done with style.css .

Step 3

  • create a new file, name it header.php . If you are working not in a special editor, but in a text editor, for example in a notebook, make sure that this is a PHP file and not a text document.
  • in the index.php file, select everything first and to the end of the DIV header . Cut it out and paste into the header.php file

Step 4

In the index.php file, replace the highlighted code that you copied with the following:

?
one
<?php get_header(); ?>

This is a special WordPress function that is responsible for including the header.php file, instead of using <? Php include (TEMPLATEPATH. '/Header.php'); ?> .

Save and refresh browsers. You should not see any changes. If the topic looks somehow wrong after you made a change, then something is wrong.

Step 4

Step 4 is almost the same as the previous one. This time:

  • create sidebar.php file
  • select everything from the beginning of the DIV tag Sidebar to its end, copy and paste into the sidebar.php file
  • then, in the index.php file, replace the highlighted one with the code <? php get_sidebar (); ?>
  • save and refresh browsers.

And again you should not see a change.

Step 5

Repeat the above operations with <div id = "footer"> for the file footer.php.

This needs to be done with each new WordPress theme to ensure optimal and proper structure of the theme.

Lesson review

  • You have created three new files: header.php , sidebar.php and footer.php .
  • You've learned three new features: get_header () , get_sidebar () and get_footer () .

Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Content Management Systems (CMS)

Terms: Content Management Systems (CMS)