Разные мобильные и основная версии сайта на WP
Category: PHP code examples
- Папка темы
- blog
- images
- initialization
- blog.css
- check_ip [мануал в архиве]
- fonts
- include
- lp
- lp_main
- mobile
- images
- initialization
- lp_main_mobile.css
- classic
- images
- initialization
- lp_main_classic.css
- lp_main_mobile.php
- lp_main_classic.php
- mobile
- lp_main
- universal
- counter.php
- consultant.php
- footer.php
- functions.php
- header.php
- index.php
- lp_main.php
- page.php
- screenshot.php
- sidebar.php
- single.php
- style.css
- blog
Дополнительные инструкции
Создание шаблона страницы landing page типа lp_main делается по:
- Как создать свой шаблон страницы в WordPress?
- Плагин определения типа устройства (разделение на моб и не моб версию)
Пример:
<?php /* Template Name: lp_main */?> <?php $detect = new Mobile_Detect; if ( $detect->isMobile() ) { <!-- Код мобильной версии --> <?php } else { ?> <!-- Код стационарной версии --> <?php } ?>
Или в нашем случае всё можно свести к коду:
<?php /* Template Name: lp_main */ $detect = new Mobile_Detect; if ( $detect->isMobile() ) { require( "lp/lp_main/lp_main_mobile.php" ); } else { require( "lp/lp_main/lp_main_classic.php" ); } ?>
Также можно подключить в конце файлы счетчиков, консультанта, защиты от копирования контента:
<?php /* Template Name: lp_main */ $detect = new Mobile_Detect; if ( $detect->isMobile() ) { require( "lp/lp_main/lp_main_mobile.php" ); } else { require( "lp/lp_main/lp_main_classic.php" ); }; require( "universal/counter.php" ); require( "universal/consultant.php" ); require( "check_ip/access_to_context_menu.php" ); ?>