• Resolved AdmiralRob

    (@admiralrob)


    I’m looking to set the default view to List but only for the mobile. So far I’ve come up with trying to add a bit of Javascript to the header that would forward them to the /events/list/ page, but i cant’ seem to get wordpress to let me add it in just for the events page. Here’s my current code:

    
    function load_js_assets() {
        if( is_page( 'events' ) ) {
            ?>
    			<!-- FORWARD IF MOBILE -->
    			<script type="text/javascript">
    				<!--
    				if (screen.width <= 699) {
    					document.location = "/events/list/";
    				}
    				//-->
    			</script> 
    		<?php
        } 
    }
    
    add_action('wp_enqueue_scripts', 'load_js_assets');

    I’ve placed that in the functions file of my theme. Any help would be greatly appreciated!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Changing the default view to List for Mobile’ is closed to new replies.