add start and end time to month view under title

Home Forums Calendar Products Events Calendar PRO add start and end time to month view under title

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #1055772
    david
    Participant

    I have seen this https://theeventscalendar.com/knowledgebase/add-start-time-to-event-title/ but it does not add the end time

    I would like it to be”

    “event title”
    2pm-4pm

    “another event title”
    6pm to 7pm

    and so on

    I have no idea how to do this, I don’t like the hover and some of my clients can’t view the hover due to their work computer browser security so keep it simple event title and star + End times displayed please help

    #1055804
    david
    Participant

    now I can add this code:

    <div class="duration">
    <?php echo tribe_events_event_schedule_details(); ?>
    </div>

    to the bottom of plugins/the-events-calendar/src/views/month/single-event.php however this also adds the times to the mobile view and makes it look very strange so I only need it in the desktop view and not the mobile view. this is way outside my expertise

    #1056076
    Brian
    Member

    Hi,

    Thanks for using our plugins. I can help out here, but I am limited in supporting customizations.

    There is a WordPress function called wp_is_mobile() that could hide the times on mobile devices:


    <div class="duration">
    <?php
    if ( ! wp_is_mobile() ) {
    echo tribe_events_event_schedule_details();
    }
    ?>
    </div>

    That will hide it if the script thinks it is a mobile device, which is usually a tablet or phone. (resizing the browser will not hide the content)

    That might work better for you.

    If not could you provide a link in a private reply and I can take a look and see if I have another suggestion.

    Thanks

    #1056315
    david
    Participant

    doesn’t seem to remove the times from mobile view

    #1056317
    david
    Participant

    This reply is private.

    #1056331
    david
    Participant

    I am not a web guy but I have seen this page https://codex.wordpress.org/Function_Reference/wp_is_mobile

    they don’t have a ! so I will try it without the ! see if that works

    #1056333
    david
    Participant

    nope removing the ! doesn’t even display the times

    #1056334
    david
    Participant

    if all else fails I can add it to the event title with a <br> in between the title and times- although it does not look as good

    and then on mobile use some css to hide the actual start + finish times from displaying. Not really what I am after as it looks bad- see 23rd Jan http://kidsmagicworld.com.au/events/2016-01/?reloaded=true it would be nice to have the start + end times all on 1 line a slightly smaller font

    #1056335
    david
    Participant

    actually if I do a <br> and then <h6>10:00 am to 12:00 pm</h6> then it does what is needed I think I will look into having css hide times from the mobile view and this sorts it out- I’ll test to see what it looks like on mobile devices

    • This reply was modified 10 years, 3 months ago by david.
    #1056337
    david
    Participant

    bugger- in mobile view it displays the H tags so it displays Crows Nest<br><h5>10:00 am to 12:00 pm</h5> close but no cigar- this is frustrating as all hell

    • This reply was modified 10 years, 3 months ago by david.
    #1056361
    david
    Participant

    if you can’t help with the above an alternative if you could show me how is to create a custom field (a text line) and then how to echo that into the month view under the title but I forsee that the mobile view will show it on the calndar

    #1056648
    Brian
    Member

    Oh I see you put it in the event title html tags.

    I set it up like this:

    " class="url">

    And that would then only display under the title and not in the tooltip either.

    #1056915
    david
    Participant

    not looking right

     *
     */
    ?>
    
    <div id="tribe-events-event-<?php echo esc_attr( $event_id ); ?>" class="<?php tribe_events_event_classes() ?>" data-tribejson='<?php echo esc_attr( tribe_events_template_data( $post ) ); ?>'>
    	<h3><a>" class="url"><?php echo $title ?></a></h3>
    <div class="duration">
    <?php
        echo tribe_events_event_schedule_details();
    ?>
    </div>
    </div><!-- #tribe-events-event-# -->

    makes it look like this screen shot. I an not sure how or where to add the code http://kidsmagicworld.com.au/wp-content/uploads/2016/01/calno.jpg

    #1056917
    david
    Participant

    here is a screen shot of the code http://kidsmagicworld.com.au/wp-content/uploads/2016/01/thecodescreenshot.jpg and the plugins/the-events-calendar/src/views/month/single-event.php page doesn’t work like this

    #1056918
    david
    Participant

    the following code added to the functions file adds the start time- is there a way of expanding this code to also show the end time?

    /*
     * Adds start time to event titles in Month view
     */
    function tribe_add_start_time_to_event_title ( $post_title, $post_id ) {
     
        if ( !tribe_is_event($post_id) ) return $post_title;
        // Checks if it is the month view, modify this line to apply to more views
        if ( !tribe_is_month() ) return $post_title;
     
        $event_start_time = tribe_get_start_time( $post_id );
     
        if ( !empty( $event_start_time ) ) {
            $post_title = $event_start_time . ' - ' . $post_title;
        }
     
        return $post_title;
    }
    add_filter( 'the_title', 'tribe_add_start_time_to_event_title', 100, 2 );
Viewing 15 posts - 1 through 15 (of 20 total)
  • The topic ‘add start and end time to month view under title’ is closed to new replies.