Change the start time of the week view

Home Forums Calendar Products Events Calendar PRO Change the start time of the week view

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1132070
    Lucy
    Participant

    Hello, is it possible to change the start time in the week view form 12am to my custom time – 8am? I cannot see this in the settings – only the cut-off time if you have events in to the night.

    It is currently unused space on the week view as my events do not start until 8am.

    Thanks
    Lucy

    #1132511
    Andras
    Keymaster

    Hi Lucy,

    Thanks for reaching out.

    You can achieve the desired effect if you add the below snippet to your theme’s function.php file:


    add_filter( 'tribe_events_week_get_hours', 'filter_week_hours' );

    function filter_week_hours( $hours ) {
    $hour = 0;

    foreach ( $hours as $key => $formatted_hour ) {
    if ( $hour < 7 || $hour > 18 ) {
    unset( $hours[ $hour ] );
    }

    $hour ++;
    }

    return $hours;
    }

    Change the timings in the middle of the code as per your need.

    Let me know if this helps.

    Cheers,
    Andras

    #1134366
    Lucy
    Participant

    HI Andra,

    Thank you very much for your reply. I have added this code to my functions.php file – but it is breaking the site – I get the error as per the screens hot attached, a HTTP 500 error.

    Here is the rest of my functions file code if you can see if your code is clashing with anything..?

    <?php 
    	
    // ===== Enqueue ALL Styles
    function styles() {
    	
    	// My Stylesheet
    	wp_enqueue_style( 'styles', get_template_directory_uri() . '/style.css' );
    	
    	// Flexslider
    	wp_enqueue_style( 'flexslider', get_template_directory_uri() . '/flexslider/flexslider.css' );
    	
    	// Magnific
    	wp_enqueue_style( 'magnific', get_template_directory_uri() . '/magnific/magnific.css' );
    
    	//FontAwesome
    	wp_enqueue_style( 'prefix-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css', array(), NULL );
    	
    	//IonIcon
    	wp_enqueue_style( 'ion-icon', get_template_directory_uri() . '/ion/ionicons.min.css', array(), NULL );
    	
    	//GoogleFont
    	wp_enqueue_style( 'pre-sans', 'https://fonts.googleapis.com/css?family=PT+Sans:400,700', array(), NULL );
    	
    }
    add_action( 'wp_enqueue_scripts', 'styles' );
    
    // ===== Enqueue jQuery
    if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
    function my_jquery_enqueue() {
       wp_deregister_script('jquery');
       wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js", false, null);
       wp_enqueue_script('jquery');
    }
    
    // ===== Enqueue ALL Scripts
    function scripts() {
    	
    	// Easing
    	wp_enqueue_script( 'easing', get_template_directory_uri() . '/js/easing.js', array(), NULL, true );
    	
    	// My Scripts
    	wp_enqueue_script( 'myscripts', get_template_directory_uri() . '/js/scripts.js', array(), NULL, true );
    
    	// FastClick
    	wp_enqueue_script( 'fastclick', get_template_directory_uri() . '/js/fastclick.js', array(), NULL, true );
    	
    	// Flexslider
    	wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/flexslider/jquery.flexslider-min.js', array(), NULL, true );
    	wp_enqueue_script( 'flexslider2', get_template_directory_uri() . '/flexslider/jquery.flexslider-init.js', array(), NULL, true );
    	
    	// Magnific
    	wp_enqueue_script( 'magnific', get_template_directory_uri() . '/magnific/magnific.min.js', array(), NULL, true );
    	wp_enqueue_script( 'magnific2', get_template_directory_uri() . '/magnific/magnific.init.js', array(), NULL, true );
    	
    }
    add_action( 'wp_enqueue_scripts', 'scripts' );
    
    // Remove Emojis
    function disable_wp_emojicons() {
    
      // all actions related to emojis
      remove_action( 'admin_print_styles', 'print_emoji_styles' );
      remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
      remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
      remove_action( 'wp_print_styles', 'print_emoji_styles' );
      remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
      remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
      remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
    
      // filter to remove TinyMCE emojis
      add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' );
    }
    add_action( 'init', 'disable_wp_emojicons' );
    
    function disable_emojicons_tinymce( $plugins ) {
      if ( is_array( $plugins ) ) {
        return array_diff( $plugins, array( 'wpemoji' ) );
      } else {
        return array();
      }
    }
    
    	
    // Add Favicon 
    
    function add_favicon() {
      	$favicon_url = site_url() . '/favicon.png';
    	echo '<link rel="shortcut icon" href="' . $favicon_url . '" />';
    }
    
    add_action('login_head', 'add_favicon');
    add_action('admin_head', 'add_favicon');
    add_action('wp_head','add_favicon');
    
    // Add custom small thumbnail size
    add_image_size( 'small_thumb', 70, 70, array( 'center', 'center' ) );
    
    // Hide Admin Bar
    show_admin_bar( false );
    
    // Move Yoast To Bottom of Editor Page
    add_filter( 'wpseo_metabox_prio', function() { return 'low';});
    
    // Thumbnails to CPT
    add_theme_support( 'post-thumbnails' ); 
    
    // Change Post Navigation Text
    
    add_filter( 'next_post_link' , 'my_nav_buttons_text' , 10, 4);
    add_filter( 'previous_post_link' , 'my_nav_buttons_text' , 10, 4);
     
    function my_nav_buttons_text($output, $format, $link, $post ) {
     switch ( current_filter() ) {
     case 'previous_post_link':
     $text = 'Previous post';
     $rel = 'prev';
     $class= 'prev';
     break;
     
     case 'next_post_link':
     $text = 'Next post';
     $rel = 'next';
     $class= 'next';
     break;
     }
     return sprintf('<a href="%1$s" rel="%3$s" class="%4$s" rel="nofollow">%2$s</a>' , get_permalink( $post ), $text, $rel, $class );
    }
    
    // Browser Detection Body class
    
    add_filter('body_class','browser_body_class');
    function browser_body_class($classes) {
    	global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
    
    	if($is_lynx) $classes[] = 'lynx';
    	elseif($is_gecko) $classes[] = 'gecko';
    	elseif($is_opera) $classes[] = 'opera';
    	elseif($is_NS4) $classes[] = 'ns4';
    	elseif($is_safari) $classes[] = 'safari';
    	elseif($is_chrome) $classes[] = 'chrome';
    	elseif($is_IE) $classes[] = 'ie';
    	else $classes[] = 'unknown';
    
    	if($is_iphone) $classes[] = 'iphone';
    	return $classes;
    }
    
    // Register Navigation
    add_theme_support('menus');
    
    function main_nav()
    {
    	wp_nav_menu(
    	array(
    		'theme_location'  => 'main-menu',
    		'container'       => '',
    		'container_class' => 'menu-container',
    		'menu_class'      => 'nav-menu centered',
    		)
    	);
    }
    
    function register_bbm__menu()
    {
        register_nav_menus(array( // Using array to specify more menus if needed
            'main-menu' => __('Main Menu', 'bbm_blank'), // Main Navigation
        ));
    }
    add_action('init', 'register_bbm__menu'); // Add bbm_ Blank Menu
    
    function mobile_nav()
    {
    	wp_nav_menu(
    	array(
    		'theme_location'  => 'mobile-menu',
    		'container'       => '',
    		'container_class' => 'mobile-container',
    		'menu_class'      => 'nav-menu centered',
    		)
    	);
    }
    
    function register_bbm__menu2()
    {
        register_nav_menus(array( // Using array to specify more menus if needed
            'mobile-menu' => __('Mobile Menu', 'bbm_blank'), // Main Navigation
        ));
    }
    add_action('init', 'register_bbm__menu2'); // Add bbm_ Blank Menu
    
    // ACF Options
    if( function_exists('acf_add_options_page') ) {
    	
    	acf_add_options_page();
    	
    }
    
    //Allow SVG upload
    
    function cc_mime_types($mimes) {
      $mimes['svg'] = 'image/svg+xml';
      return $mimes;
    }
    add_filter('upload_mimes', 'cc_mime_types');
    
    // Rewrites Event Calendar Organisers to Teachers
    add_filter( 'tribe_events_register_organizer_type_args', function( $args ) {
    $args['rewrite']['slug'] = 'teachers';
    return $args;
    } );
    
    // Reorder Get Organisers
    function tribe_get_organizers_custom( $deprecated = null, $posts_per_page = -1 ) {
    	if ( null !== $deprecated ) {
    		_deprecated_argument( __FUNCTION__, '3.0', 'This parameter is no longer supported.' );
    	}
    
    	$organizers = get_posts(
    		array(
    			'post_type' => Tribe__Events__Main::ORGANIZER_POST_TYPE,
    			'posts_per_page' => $posts_per_page,
    			'orderby' => 'date',
    			'order' => 'ASC'
    		)
    	);
    
    	return $organizers;
    }
    
    // Contact page Anji/Bridget
    function tribe_get_organizers_contact( $deprecated = null, $posts_per_page = -1 ) {
    	if ( null !== $deprecated ) {
    		_deprecated_argument( __FUNCTION__, '3.0', 'This parameter is no longer supported.' );
    	}
    
    	$organizers = get_posts(
    		array(
    			'post_type' => Tribe__Events__Main::ORGANIZER_POST_TYPE,
    			'posts_per_page' => $posts_per_page,
    			'orderby' => 'date',
    			'order' => 'ASC',
    			'post__in' => array(64, 82)
    		)
    	);
    
    	return $organizers;
    }
    
    // Customised Events Categories 
    function tribe_get_event_categories_custom( $post_id = null, $args = array() ) {
    	$events_label_singular = tribe_get_event_label_singular();
    
    	$post_id    = is_null( $post_id ) ? get_the_ID() : $post_id;
    	$defaults   = array(
    		'echo'         => false,
    		'label'        => null,
    		'label_before' => '<div>',
    		'label_after'  => '</div>',
    		'before' => '<div class="event-cats">',
    		'after' => '</div>',
    	);
    	$args       = wp_parse_args( $args, $defaults );
    	$categories = tribe_get_event_taxonomy( $post_id, $args );
    
    	// check for the occurrences of links in the returned string
    	if ( null === $args[ 'label' ] ) {
    		$label = sprintf(
    			/* translators: %s is the singular translation of "Event" */
    			_nx( '%s Category', '%s Categories', substr_count( $categories, '<a href' ), 'category label', 'the-events-calendar' ),
    			$events_label_singular
    		);
    	}
    	else {
    		$label = $args[ 'label' ];
    	}
    
    	$html = ! empty( $categories ) ? sprintf(
    		$categories
    	) : '';
    	if ( $args['echo'] ) {
    		echo apply_filters( 'tribe_get_event_categories', $html, $post_id, $args, $categories );
    	} else {
    		return apply_filters( 'tribe_get_event_categories', $html, $post_id, $args, $categories );
    	}
    }
    
    function multiple_teachers( $exclude = array() ) {
    
    	$organizers = get_posts(
    		array(
    			'post_type' => Tribe__Events__Main::ORGANIZER_POST_TYPE,
    			'posts_per_page' => -1,
    			'post__in' => $exclude
    		)
    	);
    
    	return $organizers;
    }
    
    // Pre populate forms for classes enquiry
    
    function populate_dropdown($form){
    	
    	
        // only populating drop down for form id 2
        if($form["id"] == 3){
    	   
    	   
    		// Vars
    
    	   //Reading posts for the Camp Sessions post type;
            $args = array(
               'posts_per_page' => -1,
               'post_type'      => 'tribe_events',
               'orderby'        => 'title',
               'order'          => 'ASC',
               'tax_query'	=> array(
    		        array(
    		            'taxonomy'  => 'tribe_events_cat',
    		            'field'     => 'slug',
    		            'terms'     =>  array( 'workshops', 'community' ),
    		            'operator'  => 'NOT IN'
    		        )
    			)
            );
            
            $posts = get_posts ( $args );
    
    	    //Creating drop down item array.
    	    $items = array();
    	
    	    //Adding post titles to the items array
    	    foreach($posts as $post)
    	        $items[] = array("value" => $post->post_title, "text" => $post->post_title);
    	
    	    //Adding items to field id 14. You can get the field id by looking at the field name on the form.
    	    foreach($form["fields"] as &$field)
    	        if($field["id"] == 20 || $field["id"] == 21 || $field["id"] == 22){
    	            $field["choices"] = $items;
    	        }
    	      
    	
    	    return $form;
    	   
        }
        else{
    	    return $form;
        }
        
    }
    
    add_filter("gform_pre_render", "populate_dropdown");
    add_filter("gform_admin_pre_render", "populate_dropdown");
    
    // Add Excerpts to Pages
    add_action( 'init', 'my_add_excerpts_to_pages' );
    function my_add_excerpts_to_pages() {
         add_post_type_support( 'page', 'excerpt' );
    }
    
    // Limit number of word in excerpt - call with echo excerpt(30) - change number in brackets
    function excerpt($limit) {
      $excerpt = explode(' ', get_the_excerpt(), $limit);
      if (count($excerpt)>=$limit) {
        array_pop($excerpt);
        $excerpt = implode(" ",$excerpt).'...';
      } else {
        $excerpt = implode(" ",$excerpt);
      }	
      $excerpt = preg_replace('<code>\[[^\]]*\]</code>','',$excerpt);
      return $excerpt;
    }
     
    function content($limit) {
      $content = explode(' ', get_the_content(), $limit);
      if (count($content)>=$limit) {
        array_pop($content);
        $content = implode(" ",$content).'...';
      } else {
        $content = implode(" ",$content);
      }	
      $content = preg_replace('/\[.+\]/','', $content);
      $content = apply_filters('the_content', $content); 
      $content = str_replace(']]>', ']]>', $content);
      return $content;
    }
    
    // GForm Confirmation Anchor	
    
    add_filter( 'gform_confirmation_anchor', '__return_true' );
    
    // Take 'Private' prefix off all posts marked as private
    add_filter( 'private_title_format', 'bl_remove_private_title' );
    function bl_remove_private_title( $title ) {
        // Return only the title portion as defined by %s, not the additional 
        // 'Private: ' as added in core
        return "%s";
    }
    
    // Change the time the weekly calendarview, starts
    add_filter( 'tribe_events_week_get_hours', 'filter_week_hours' );
    
    function filter_week_hours( $hours ) {
      $hour = 0;
    
      foreach ( $hours as $key => $formatted_hour ) {
        if ( $hour < 7 || $hour > 18 ) {
          unset( $hours[ $hour ] );
        }
    
        $hour ++;
      }
    
      return $hours;
    }
    ?>

    Thank you very much,
    Lucy

    #1134648
    Andras
    Keymaster

    Hey Lucy,

    That’s a massive functions.php file. 🙂 I went through it, but I don’t see anything that would be clashing with it. If you remove the snippet I sent you then all works fine?

    Could you share with me your system information? Here’s a nice guide for that. https://theeventscalendar.com/knowledgebase/sharing-sys-info/
    It might shed some light on things.

    Also, you could run a test for conflicting plugins and themes. Here’s how you can do that. https://theeventscalendar.com/knowledgebase/testing-for-conflicts/

    Waiting to hear from you.

    Cheers,
    Andras

    #1134665
    Andras
    Keymaster

    Lucy, potentially you can try deleting the closing ‘?>’ tag from the functions.php file. It is not obligatory any more. In some cases it helps.

    Cheers,
    Andras

    #1135048
    Lucy
    Participant

    HI Andras,

    Yes I removed the closing ?> php tag form my functions files as i understand that is not needed, but this does not stop the code you gave me breaking the site when i add it.

    Here is my system information as you asked – does this give you any more information in to what the problem could be?

    HOME URL
    http://lucyryderdev.uk/yoganew
    SITE URL
    http://lucyryderdev.uk/yoganew
    INSTALL KEYS
    events-calendar-pro = 90913cb97048d944d43e5a831b850a6f21049d4d
    WORDPRESS VERSION
    4.5.3
    PHP VERSION
    5.6.22
    PLUGINS
    Gravity Forms version 2.0.2 by rocketgenius(http://www.rocketgenius.com)
    Admin Menu Editor version 1.6.2 by Janis Elsts(http://w-shadow.com/blog/)
    Advanced Custom Fields PRO version 5.3.9.2 by Elliot Condon(http://www.elliotcondon.com/)
    Akismet version 3.1.11 by Automattic(https://automattic.com/wordpress-plugins/)
    Duplicate Post version 2.6 by Enrico Battocchi(http://lopo.it)
    The Events Calendar PRO version 4.2.1 by Modern Tribe, Inc.(http://m.tri.be/20)
    Find and Replace All version 1.0 by Taraprasad Swain(http://www.taraprasad.com)
    Google Analytics by MonsterInsights version 5.5 by MonsterInsights(https://www.monsterinsights.com/)
    Gravity Forms MailChimp Add-On version 3.7.1 by rocketgenius(http://www.rocketgenius.com)
    Post Expirator version 2.1.4 by Aaron Axelsen(http://postexpirator.tuxdocs.net/)
    WordPress Post Type Archive Links version 1.3.1 by Stephen Harris(https://github.com/stephenharris/)
    Post Types Order version 1.8.9.2 by Nsp Code(http://www.nsp-code.com)
    Regenerate Thumbnails version 2.2.6 by Alex Mills (Viper007Bond)(http://www.viper007bond.com/)
    Simple Tooltips version 2.1.3 by Justin Saad(http://www.clevelandwebdeveloper.com)
    SlickNav Mobile Menu version 1.7.5 by Neil Gee(http://wpbeaches.com)
    The Events Calendar version 4.2.1.1 by Modern Tribe, Inc.(http://m.tri.be/1x)
    TinyMCE Advanced version 4.3.10.1 by Andrew Ozz(http://www.laptoptips.ca/)
    WCK – Custom Fields and Custom Post Types Creator version 1.2.9 by Cozmoslabs, Madalin Ungureanu, Cristian Antohe(http://www.cozmoslabs.com)
    Yoast SEO version 3.3.4 by Team Yoast(https://yoast.com/)
    WP-Optimize version 1.9.1 by Ruhani Rabin(https://github.com/ruhanirabin/WP-Optimize)
    WP-Paginate version 1.3.1 by Noah Cinquini(http://www.studiofuel.com)
    WP Super Cache – Clear all cache version 1.3.1 by Apasionados.es(http://apasionados.es/)
    NETWORK PLUGINS

    MU PLUGINS

    THEME

    MULTISITE

    SETTINGS
    schema-version = 4.2.1.1
    recurring_events_are_hidden = exposed
    previous_ecp_versions =
    Array
    (
    [0] => 0
    [1] => 4.1.2
    [2] => 4.1.3
    [3] => 4.1.4
    [4] => 4.2
    [5] => 4.2.1
    )
    latest_ecp_version = 4.2.1.1
    last-update-message = 4.1.4
    disable_metabox_custom_fields = hide
    pro-schema-version = 4.2.1
    earliest_date = 2016-06-01 19:35:00
    earliest_date_markers =
    Array
    (
    [0] => 343
    )
    latest_date = 2016-11-20 20:00:00
    latest_date_markers =
    Array
    (
    [0] => 1819
    )
    stylesheetOption = tribe
    tribeEventsTemplate =
    tribeEnableViews =
    Array
    (
    [0] => month
    [1] => week
    )
    viewOption = month
    tribeDisableTribeBar = 1
    hideLocationSearch = 1
    hideRelatedEvents = 1
    week_view_hide_weekends =
    monthEventAmount = 3
    enable_month_view_cache =
    dateWithYearFormat = jS F Y
    dateWithoutYearFormat = F j
    monthAndYearFormat = F Y
    weekDayFormat = D jS
    dateTimeSeparator = @
    timeRangeSeparator = –
    datepickerFormat = 0
    tribeEventsBeforeHTML =
    tribeEventsAfterHTML =
    donate-link =
    postsPerPage = 25
    liveFiltersUpdate =
    hideSubsequentRecurrencesDefault = 1
    userToggleSubsequentRecurrences =
    recurrenceMaxMonthsBefore = 2
    recurrenceMaxMonthsAfter = 2
    showComments =
    showEventsInMainLoop =
    eventsSlug = timetable
    singleEventSlug = event
    multiDayCutoff = 00:00
    defaultCurrencySymbol = £
    reverseCurrencyPosition =
    embedGoogleMaps =
    geoloc_default_geofence = 25
    geoloc_default_unit = miles
    embedGoogleMapsZoom = 10
    debugEvents =
    tribe_events_timezone_mode = event
    tribe_events_timezones_show_zone =
    eventsDefaultOrganizerID = 0
    eventsDefaultVenueID = 116
    eventsDefaultAddress =
    eventsDefaultCity =
    eventsDefaultState =
    eventsDefaultProvince =
    eventsDefaultZip =
    defaultCountry =
    eventsDefaultPhone =
    tribeEventsCountries =
    WORDPRESS TIMEZONE
    Europe/London
    SERVER TIMEZONE
    UTC
    COMMON LIBRARY DIR
    /var/sites/l/lucyryderdev.uk/public_html/yoganew/wp-content/plugins/the-events-calendar/common/src/Tribe
    COMMON LIBRARY VERSION
    4.2.1.1

    #1135762
    Andras
    Keymaster

    Hi Lucy,

    Thanks for sharing your system information.

    I went through your functions.php file again and I don’t really see anything that it would clash with. That of course doesn’t mean it does not, unfortunately.

    Did you by chance manage to do a test for conflicting plugins / theme ? https://theeventscalendar.com/knowledgebase/testing-for-conflicts/

    If the test doesn’t bring any result, then the next thing to check is your functions.php file. Basically removing or commenting out everything and start adding them back one by one (or 2 by 2) to see if any of them cause a conflict.

    I’ll be waiting for the results and we can take it forward from there.

    Cheers,
    Andras

    #1135887
    Lucy
    Participant

    HI Andras,

    I tried turning all my plugins off and on, and commenting out my functions.php file code by code – but nothing worked – so I had a another Google around and found this post where it’s done slightly differently – and it worked:-

    Trying to limit hours displayed in WEEK VIEW

    Thanks very much for your time,
    Lucy

    #1135937
    Andras
    Keymaster

    Hi Lucy,

    I am glad to see you got this figured. I guess then it was the curly – non-curly apostrophes issue… that’s always a difficult one to spot. I’m happy it works now!

    I am going to go ahead and close this ticket. If you have a similar issue or another in the future, please do not hesitate to create a new one. We’ll be glad to help!

    Cheers,
    Andras

    PS: If you like our plugin, we would be happy to receive a review in the wordpress.org repository. Thanks!

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Change the start time of the week view’ is closed to new replies.