Book Image

WordPress Mobile Web Development: Beginner's Guide

By : RACHEL MCCOLLIN
Book Image

WordPress Mobile Web Development: Beginner's Guide

By: RACHEL MCCOLLIN

Overview of this book

The chances are that more of your WordPress website visitors are using mobiles, or more clients are demanding responsive or mobile sites. If you can use WordPress to build mobile-friendly sites you can win more business from clients and more traffic for your site. "WordPress Mobile Web Development Beginner's Guide" will benefit you whether you've dabbled in WordPress or worked with it for years. It will help you identify which approach to mobile is most appropriate for your site (responsive, mobile, or web app) and learn how to make each one work, demonstrating a variety of techniques from the simple to the more complex, working through clear practical examples and applying these to your own website. Start by quickly making a WordPress site mobile-friendly, using off the shelf plugins and responsive themes, choosing the best ones for you and customising them. This leads into responsive theme design, with advice on layout, images and navigation. Finally, learn how to build a web app in WordPress, making use of plugins, APIs and custom code. If you need to hit the ground running with mobile WordPress development, then this book is for you. With practical examples and exercises from the beginning, it will help you build your first mobile WordPress site without having to learn aspects of WordPress or mobile development that aren't relevant. It will also help you understand which approaches work and why, so you can apply this knowledge to future projects.
Table of Contents (18 chapters)
WordPress Mobile Web Development Beginner's Guide
Credits
About the Author
About the Reviewers
Acknowledgement
www.PacktPub.com
Preface

Time for action—coding mobile menus into the theme


Our two new menus will be displayed at different places, one in the header and one at the bottom of the page. To do this, we will need to add some new code to two theme files—header.php and footer.php. Perform the following steps for coding mobile menus into the theme:

  1. 1. First, we will open header.php and look for the code containing the existing menu as follows:

    <nav class="access">
    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
    </nav><!-- .access -->
    
  2. 2. As our new menu needs to be styled differently, we'll add the menu and assign a unique class to it, which we can use in our CSS.

    The code we will add to display the mobile-top menu is as follows:

    <?php wp_nav_menu( array( 'menu' => 'mobile-top', 'container_class' => 'menu-header', menu-class => 'mobile-top-menu' ) ); ?>
    
  3. 3. But, we also need to ensure this menu only displays on mobile devices,...