Что такое WordPress Тема ?

    Это набор файлов состоящий из :

●   style.css                 Информация и стили темы
●   Index.php, footer.php,    Шаблоны темы, файлы
    header.php и т.д          содержащие кусочки PHP кода.
●   Functions.php             Файл функций темы
●   JavaScript, images, css   Остальные файлы темы
Style.css
                         /*
                         Theme Name: P2
                         Theme URI: http://p2theme.com/
                         Author: Automattic
                         Author URI: http://automattic.com/
●   Обьявление темы      Description: A group blog theme for short update messages,
                         inspired by Twitter. Featuring: Hassle-free posting from the
                         front page. Perfect for group blogging, or as a liveblog
                         theme. Dynamic page updates. Threaded comment display on the
●   Информация о теме    front page. In-line editing for posts and comments. Live tag
                         suggestion based on previously used tags. A show/hide feature
                         for comments, to keep things tidy. Real-time notifications
                         when a new comment or update is posted. Super-handy keyboard

    Таблица стилей
                         shortcuts. Helvetica Neue for you modern font lovers.
●
                         Version: 1.4.2
                         Tags: blue, two-columns, fixed-width, rtl-language-support,
                         right-sidebar, white, light, front-page-post-form,
                         translation-ready, custom-background, custom-header, custom-
                         menu, post-formats, sticky-post, theme-options
                         License: GNU General Public License v2.0
                         License URI: http://www.gnu.org/licenses/gpl-2.0.html

                         This theme, like WordPress, is licensed under the GPL.
                         Use it to make something cool, have fun, and share what
                         you've learned with others.
                         */
Файлы шаблонов темы
    Header.php
                              <?php
                              /**
                               * Header template.
                               * @package P2
    Содержит в себе всю        */
    верхню часть сайта,       ?>
    которая не меняется для   <!DOCTYPE html>
                              <html <?php language_attributes(); ?>>
    всех страниц.             <head profile="http://gmpg.org/xfn/11">
                              <meta http-equiv="Content-Type" content="<?php
●   Обязательная часть        bloginfo( 'html_type' ); ?>; charset=<?php
                              bloginfo( 'charset' ); ?>" />
    wp_head(), используется   <title><?php wp_title( '&laquo;', true, 'right' ); ?> <?
    для хуков.                php bloginfo( 'name' ); ?></title>
                              <link rel="stylesheet" href="<?php
                              bloginfo( 'stylesheet_url' ); ?>" type="text/css"
●   Вызывается с помощью      media="screen" />
                              <?php wp_head(); ?>
    get_header();             </head>
                              <body <?php body_class(); ?>>
●   get_sidebar(); вызывает   <div id="header">
    шаблон sidebar.php        <div role="navigation">
                              <?php wp_nav_menu( array( 'theme_location' => 'primary',
                              'fallback_cb'     => '__return_false', ) ); ?>
                              </div>
                              </div>
                              <div id="wrapper">
                              <?php get_sidebar(); ?>
Footer.php

●   Содержит в себе
    неизменную нижнюю         </div><!--
                              div#wrapper -->
    часть сайта
                              <?php wp_footer(); ?
                              >
●   Обязательно содержит
                              </body>
    wp_footer перед
    закрывающимся </body>   </html>

●   Вызывается с помощью
    get_footer();
Index.php
                                <?php get_header(); ?>
                                <?php if ( have_posts() ) : ?>


                                <?php while ( have_posts() ) : the_post(); ?>
                                         <?php p2_load_entry(); ?>
●   Основной шаблон для         <?php endwhile; ?>
    отображения контента
                                <?php else : ?>
●   Одного его достаточно для   <li class="no-posts">

    отображения любых                <h3><?php _e( 'No posts yet!', 'p2' ); ?
                                ></h3>
    разделов сайта.             </li>
                                <?php endif; ?>
●   Основная часть - цикл       </ul>
    WordPress
                                <div class="navigation">
                                <p class="nav-older"><?php next_posts_link( __(
                                '&larr; Older posts', 'p2' ) ); ?></p>
                                <p class="nav-newer"><?php previous_posts_link(
                                __( 'Newer posts &rarr;', 'p2' ) ); ?></p>
                                </div>
                                <?php get_footer(); ?>
Sidebar.php
                           <?php
                           /**
                            * Sidebar template.
                            *
●   Служит для вывода       * @package P2
                            */
    виджетов темы.         ?>
                           <?php if ( !p2_get_hide_sidebar() ) : ?>

    Может быть несколько
                           <div id="sidebar">
●
                           <?php do_action( 'before_sidebar' ); ?>

    сайдбаров.             <ul>
                           <?php
●   Содержит дефолтные     if ( !function_exists( 'dynamic_sidebar' ) || !
                           dynamic_sidebar() ) {

    виджеты                the_widget( 'P2_Recent_Comments', array(),
                           array( 'before_widget' => '<li> ', 'after_widget' =>
                           '</li>', 'before_title' =>'<h2>', 'after_title' =>
                           '</h2>' ) );
●   Нужно подключать в     the_widget( 'P2_Recent_Tags', array(),
                           array( 'before_widget' => '<li> ', 'after_widget' =>
    functions.php          '</li>', 'before_title' =>'<h2>', 'after_title' =>
                           '</h2>' ) );
                           }
                           ?>
                           </ul>

                           <div class="clear"></div>

                           </div> <!-- // sidebar -->
                           <?php endif; ?>
Functions.php
                              Подключение виджетов:
●
    Нужен для добавления
                              register_widget( 'P2_Widget' );
    функционала темы
                              register_sidebar( array(
●   Подключение виджетов
                                'name' => __( 'Main Sidebar',
●
    Изменение стандартных       'P2' ),
    функций                     'id' => 'sidebar-1',
●
    Добавление опций темы       before_widget' => '<aside
                                id="%1$s" class="widget
●   Подключение локализации     %2$s">',
                                'after_widget' => "</aside>",
                                'before_title' => '<h3
                                class="widget-title">',
                                'after_title' => '</h3>',
                              ) );
Остальные шаблоны

  ●   Page.php
  ●   Single.php
  ●   Search.php
  ●   Category.php
  ●   404.php
  ●   Page templates
  ●   И т.д.

Wordpress theme

  • 1.
    Что такое WordPressТема ? Это набор файлов состоящий из : ● style.css Информация и стили темы ● Index.php, footer.php, Шаблоны темы, файлы header.php и т.д содержащие кусочки PHP кода. ● Functions.php Файл функций темы ● JavaScript, images, css Остальные файлы темы
  • 2.
    Style.css /* Theme Name: P2 Theme URI: http://p2theme.com/ Author: Automattic Author URI: http://automattic.com/ ● Обьявление темы Description: A group blog theme for short update messages, inspired by Twitter. Featuring: Hassle-free posting from the front page. Perfect for group blogging, or as a liveblog theme. Dynamic page updates. Threaded comment display on the ● Информация о теме front page. In-line editing for posts and comments. Live tag suggestion based on previously used tags. A show/hide feature for comments, to keep things tidy. Real-time notifications when a new comment or update is posted. Super-handy keyboard Таблица стилей shortcuts. Helvetica Neue for you modern font lovers. ● Version: 1.4.2 Tags: blue, two-columns, fixed-width, rtl-language-support, right-sidebar, white, light, front-page-post-form, translation-ready, custom-background, custom-header, custom- menu, post-formats, sticky-post, theme-options License: GNU General Public License v2.0 License URI: http://www.gnu.org/licenses/gpl-2.0.html This theme, like WordPress, is licensed under the GPL. Use it to make something cool, have fun, and share what you've learned with others. */
  • 3.
    Файлы шаблонов темы Header.php <?php /** * Header template. * @package P2 Содержит в себе всю */ верхню часть сайта, ?> которая не меняется для <!DOCTYPE html> <html <?php language_attributes(); ?>> всех страниц. <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php ● Обязательная часть bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" /> wp_head(), используется <title><?php wp_title( '&laquo;', true, 'right' ); ?> <? для хуков. php bloginfo( 'name' ); ?></title> <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" ● Вызывается с помощью media="screen" /> <?php wp_head(); ?> get_header(); </head> <body <?php body_class(); ?>> ● get_sidebar(); вызывает <div id="header"> шаблон sidebar.php <div role="navigation"> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'fallback_cb' => '__return_false', ) ); ?> </div> </div> <div id="wrapper"> <?php get_sidebar(); ?>
  • 4.
    Footer.php ● Содержит в себе неизменную нижнюю </div><!-- div#wrapper --> часть сайта <?php wp_footer(); ? > ● Обязательно содержит </body> wp_footer перед закрывающимся </body> </html> ● Вызывается с помощью get_footer();
  • 5.
    Index.php <?php get_header(); ?> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php p2_load_entry(); ?> ● Основной шаблон для <?php endwhile; ?> отображения контента <?php else : ?> ● Одного его достаточно для <li class="no-posts"> отображения любых <h3><?php _e( 'No posts yet!', 'p2' ); ? ></h3> разделов сайта. </li> <?php endif; ?> ● Основная часть - цикл </ul> WordPress <div class="navigation"> <p class="nav-older"><?php next_posts_link( __( '&larr; Older posts', 'p2' ) ); ?></p> <p class="nav-newer"><?php previous_posts_link( __( 'Newer posts &rarr;', 'p2' ) ); ?></p> </div> <?php get_footer(); ?>
  • 6.
    Sidebar.php <?php /** * Sidebar template. * ● Служит для вывода * @package P2 */ виджетов темы. ?> <?php if ( !p2_get_hide_sidebar() ) : ?> Может быть несколько <div id="sidebar"> ● <?php do_action( 'before_sidebar' ); ?> сайдбаров. <ul> <?php ● Содержит дефолтные if ( !function_exists( 'dynamic_sidebar' ) || ! dynamic_sidebar() ) { виджеты the_widget( 'P2_Recent_Comments', array(), array( 'before_widget' => '<li> ', 'after_widget' => '</li>', 'before_title' =>'<h2>', 'after_title' => '</h2>' ) ); ● Нужно подключать в the_widget( 'P2_Recent_Tags', array(), array( 'before_widget' => '<li> ', 'after_widget' => functions.php '</li>', 'before_title' =>'<h2>', 'after_title' => '</h2>' ) ); } ?> </ul> <div class="clear"></div> </div> <!-- // sidebar --> <?php endif; ?>
  • 7.
    Functions.php Подключение виджетов: ● Нужен для добавления register_widget( 'P2_Widget' ); функционала темы register_sidebar( array( ● Подключение виджетов 'name' => __( 'Main Sidebar', ● Изменение стандартных 'P2' ), функций 'id' => 'sidebar-1', ● Добавление опций темы before_widget' => '<aside id="%1$s" class="widget ● Подключение локализации %2$s">', 'after_widget' => "</aside>", 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) );
  • 8.
    Остальные шаблоны ● Page.php ● Single.php ● Search.php ● Category.php ● 404.php ● Page templates ● И т.д.