Improving the Back Button Behavior in WordPress Pages

The back button in your AppPresser app works by interacting with pushPage windows. When you open a menu item, it launches a pushPage window over the top of the home screen which the back button will close to move back to the home screen.

If your app relies on clicking through many links in WordPress Pages you may have found that the back button becomes confusing as it closes the pushPage window moving the user all the way back to the home screen instead of back a single page. To combat this, you can add the "push-page" class to a link in WordPress to have that link open in its own pushPage window so the user can go back to the page before it.

Adding that push-page class manually can be slow and difficult so a better solution might be to automate it. We can do this with some jQuery added to our footer.php file (Be sure to copy ap3-ion-theme/footer.php to an AP3 Child Theme first). The code below looks for all <a> tags within the 'main' class and applies the push-page class to them. Depending on your site and app setup you may not want the push-page class on all links so you could change .main to be a more specific selector. For example, changing it to .bbpress would only add the class to bbpress pages where having the stacked push-page windows is more important for your users.

<script><br>jQuery(document).on('ready', function(){<br>   jQuery(".main a").addClass("push-page"); <br>});<br></script>