How To Set Different Page When Viewing Mobile or Smartphones in WordPress?
This is the common things we encounter when we wanted to see different page on our website when we view using our smartphones or mobile devices from our website blog or any other website, this simple solution is very useful to improve user experience and to make your landing page or homepage load faster, this solution is effective for iPhone 4, iPhone 4s, iPhone 5, iPhone 5s, iPhone 6, iPhone 6s, iPhone 6s Plus, iPhone 7 and any other devices, you just only need to set the specific screen sizes from the code we are going to provide below.
//* Redirect homepage on mobile
add_action( 'wp_head', 'wps_params', 10 );
function wps_params() {
?>
<script>
if (window.location.pathname == '/' && jQuery(window).width() <= 480) {
window.location = "http://yoursite.com/mobile-page/";
}
</script>
<?php
}
Steps On Placing The Code
This is the common things we encounter when we wanted to see different page on our website when we view using our smartphones or mobile devices from our website blog or any other website, this simple solution is very useful to improve user experience and to make your landing page or homepage load faster, this solution is effective for iPhone 4, iPhone 4s, iPhone 5, iPhone 5s, iPhone 6, iPhone 6s, iPhone 6s Plus, iPhone 7 and any other devices, you just only need to set the specific screen sizes from the code we are going to provide below.
//* Redirect homepage on mobile
add_action( 'wp_head', 'wps_params', 10 );
function wps_params() {
?>
<script>
if (window.location.pathname == '/' && jQuery(window).width() <= 480) {
window.location = "http://yoursite.com/mobile-page/";
}
</script>
<?php
}
Steps On Placing The Code
- You need to login as administrator from your WordPress site.
- Go To Appearance>Editor and locate the functions.php
- Copy the code provided above and then paste it to the functions.php at the end of the functions.php code.
- the 480 numbers if you want to include the iPad or other screensize from this.
- Now set the link you wanted when users trying to access the homepage of your website they will redirect to see the mobile page you set from the code.
Hope this simple guide is helpful and also if you wanted to have more interesting video tutorials I suggest you subscribe the "Bryan WordPress Journey" YouTube channel.
Komentar
Posting Komentar