WordPress. Create theme. Header and footer

Главная » Tutorials » CMS » WordPress. Create theme. Header and footer

In last lesson we began to create our own template. Today we create common parts for every site page – header and footer

Header and footer code are situated in header.php and footer.php. Its code includes in index.php with get_header() and get_footer() functions. There is simple html code with some useful php functions in this files. Let’s shortly discuss functions, which we use in this tutorial:

  • bloginfo() – show site info. You can pass info parameter which you want to display, for example site name.
  • wp_title() – shows the title of current page
  • wp_head() – run ‘wp_head’ hook. Read about ‘wp_head’ hook here
  • wp_footer() – run ‘wp_footer’ hook.

In source code you can notice, we don’t include css and js files in header.php and footer.php It is recommended to include all styles and scripts in special file functions.php. This file needs to improve template functionality and for custom theme settings. Don’t confuse this file with plugins. Plugins works with sites, not with themes.
In functions.php file we have created function, which includes styles and scripts to our web site when any hook happens. Hook in wordpress is such event in javascript. For example, we run wp_enqueue_scripts hook and say, when hook starts, our custom function loadScripts will work.

Useful links:
WordPress codex (full documentation)
first steps in theme development

Подписаться на рассылку

Будьте в курсе - получайте последние статьи на свой email

Ваша подписка успешно оформлена

Pin It on Pinterest

Share This