functions - Changing the default view of "The Events Calendar" for mobile

I'm using "The Events Calendar" plugin on my site at . I’m looking to set the default view to List but o

I'm using "The Events Calendar" plugin on my site at /. 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!

I'm using "The Events Calendar" plugin on my site at https://divealaska/events/. 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!

Share Improve this question asked Aug 12, 2019 at 20:57 DauntlessRobDauntlessRob 1011 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

/events/ is the address of tribe_events posts archive, not of a single page, therefore the is_page() conditional tag does not work. You should use is_post_type_archive()

if( is_post_type_archive( 'tribe_events' ) ) {

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745247366a4618472.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信