Support

Account

Home Forums Front-end Issues Date value not loading in Firefox and Safari

Unread

Date value not loading in Firefox and Safari

  • Hi. I have a page whereby there are multiple loops loading month specific posts. Each post it loads has a number of ACF fields including a series of dates (date picker fields). These dates display fine in Chrome but in Firefox and Safari they do not, instead showing as ‘undefined NaN’. In Firefox and Safari all other content EXCEPT the dates load.

    The code I am using for the loop is posted below. Can anyone help me?

    <?php
        $month_add = 0; // current month, add value for the next months
        $low_date = date("Y-m-d", mktime(12, 0, 0, date("n")+$month_add, 1, date("Y")));
        $high_date = date("Y-m-d", mktime(12, 0, 0, date("n")+$month_add+1, 1, date("Y")));
        $args = array(
    	'post_type' => 'event',
    	'meta_key' => 'event_date',
    	'orderby' => 'meta_value_num',
    	'order' => 'ASC',
    	'showposts' => 20,
    	'meta_query' => array(
    	'relation' => 'AND',
    	    array(
    		'key' => 'event_date',
    		'value' => $low_date, // Lowest date value
    		'compare' => '>='
    	    ),
    	    array(
    		'key' => 'event_date',
    		'value' => $high_date, // Highest date value
    		'compare' => '<'
    	    )
    	)
        );
        $event_posts = new WP_Query($args);
        
        if($event_posts->have_posts()) : 
        while($event_posts->have_posts()) : 
        $event_posts->the_post();
    ?>
    
    <?php $cd_meta_box_value = get_post_meta($post->ID, 'event_date', true); { echo $cd_meta_box_value; } ?>
    
    <?php if( get_field('end_date') ): ?>
        <?php $cd_meta_box_value = get_post_meta($post->ID, 'end_date', true); { echo $cd_meta_box_value; } ?>
    <?php endif;?>
    
    ?php $cd_meta_box_value = get_post_meta($post->ID, 'location', true); { echo $cd_meta_box_value; } ?>
    
    <?php $cd_meta_box_value = get_post_meta($post->ID, 'description', true); { echo $cd_meta_box_value; } ?>
    
    <?php $cd_meta_box_value = get_post_meta($post->ID, 'contact_email', true); { echo $cd_meta_box_value; } ?>
    
    <a href="tel:<?php $cd_meta_box_value = get_post_meta($post->ID, 'contact_telephone', true); { echo $cd_meta_box_value; } ?>">
        <?php $cd_meta_box_value = get_post_meta($post->ID, 'contact_telephone', true); { echo $cd_meta_box_value; } ?>
    </a>
    
    <?php if( get_field('additional_files') ): ?><a href="<?php the_field('additional_files'); ?>" >Download file</a><?php endif;?>
    
    <?php if( get_field('more_information') ): ?>
        <a href="<?php the_field('more_information'); ?>">
            Click here for more information
        </a>
    <?php endif;?>
    
    <?php
        foreach((get_the_category()) as $category) {
            if ($category->cat_name != 'cat_to_exclude') {
                echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "%s" ), $category->name ) . '" class="' . sprintf( __( "%s" ), $category->slug ) . '" ' . '>' . $category->name.'</a> ';
    	}
        }
    ?>
    
    <?php endwhile; else: ?>
        There appear to be no events this month
    <?php endif; ?>
    <?php wp_reset_query(); ?>
Viewing 1 post (of 1 total)

The topic ‘Date value not loading in Firefox and Safari’ is closed to new replies.