• Resolved jon182

    (@brody182)


    I need help modifying the events calendar for WordPress, I need to add the day of the week under the number, and display the calendar horizontally..
    like this:
    https://i.imgur.com/bXHF2Sb.jpg

    here is the code I’m working with:

    <table class="tribe-mini-calendar" <?php tribe_events_the_mini_calendar_header_attributes() ?>>
    		<?php do_action( 'tribe_events_mini_cal_before_header' ); ?>
    		<thead class="tribe-mini-calendar-nav">
    		<tr>
    			<td colspan="7">
    				<div>
    					<?php tribe_events_the_mini_calendar_prev_link() ?>
    					<span id="tribe-mini-calendar-month"><?php tribe_events_the_mini_calendar_title() ?></span>
    					<?php tribe_events_the_mini_calendar_next_link() ?>
    					<img id="ajax-loading-mini" src="<?php echo tribe_events_resource_url( 'images/tribe-loading.gif' ) ?>" alt="loading..." />
    				</div>
    			</td>
    		</tr>
    		</thead>
    		<?php do_action( 'tribe_events_mini_cal_after_header' ); ?>
    		<?php do_action( 'tribe_events_mini_cal_before_the_grid' ); ?>
    		<thead>
    		<tr>
    			<?php foreach ( $days_of_week as $day ) : ?>
    				<th class="tribe-mini-calendar-dayofweek"><?php echo $day ?></th>
    			<?php endforeach; ?>
    
    		</tr>
    		</thead>
    
    		<tbody class="hfeed vcalendar">
    
    		<tr class="first-row">
    			<?php while (tribe_events_have_month_days()) :
    			tribe_events_the_month_day(); ?>
    
    			<?php if ($week != tribe_events_get_current_week()) :
    			$week ++; ?>
    
    		</tr>
    
    		<tr>
    			<?php endif; ?>
    
    			<th class=" <?php tribe_events_the_month_day_classes() ?>">
    				<?php tribe_get_template_part( 'pro/widgets/mini-calendar/single-day' ) ?>
    
    			</th>
    
    			<?php endwhile; ?>
    		</tr>
    
    		</tbody>
    		<?php do_action( 'tribe_events_mini_cal_after_the_grid' ); ?>
    	</table>
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter jon182

    (@brody182)

    more importantly how do I add $days_of_week under the number? I wasn’t able to achieve this.

    Hey brody182,

    Thanks for reaching out to us!

    This is definitely a cool look for the calendar that you’re trying to achieve. Unfortunately, we’re unable to provide customization support for the core plugin within these forums here.

    I apologize for the inconvenience.

    Thanks!

    Thread Starter jon182

    (@brody182)

    this is probably a quick answer for you, what i’m interested is..

    how do I apply the code below so it displays the week day in each calendar day

    <?php foreach ( $days_of_week as $day ) : ?>
    				<th class="tribe-mini-calendar-dayofweek"><?php echo $day ?></th>
    			<?php endforeach; ?>

    Hey @brody182,

    If by “display the week day” you mean that literally the weekday string is shown, like “Monday”, “Tuesday”, etc., then you can use the lowercase-L parameter for PHP’s date() function. Learn more about this here → https://php.net/manual/en/function.date.php

    You can also use WordPress version of it, the_date(). So, roughly, something like this: the_date( 'l' );

    Play around with that a bit and give both the article above and the article below a read:

    https://codex.www.ads-software.com/Formatting_Date_and_Time

    I hope this information helps!

    — George

    Thread Starter jon182

    (@brody182)

    I know what you are talking about but that will not work, if i do that I will get ( Thu Thu Thu Thu) for all days of the week.

    I need to grab the day of the week for each day

    Brook

    (@brook-tribe)

    Howdy brody182,

    Yeah I am sorry, that is not the right function for your needs. It will return pubdates not event dates and is focused on the first post of a page.

    If you want the day of the week for each one, the easiest way to do it might be to create your own version of the $days_of_week that’s actually $days_of_month. Our plugin uses wp_locale->get_weekday_abbrev for $days_of_week (https://developer.www.ads-software.com/reference/classes/wp_locale/get_weekday_abbrev/) but you would probably not need to do that if you’re not worried about an international solution. Populate your array with every possible day of the month so 5 weeks of Mon-Sun. From there you determine what the start day of the month and how long the month is using PHP’s date utils, trim the days from the start and end of the month that you dont need. Now that you have that you can have an increment the counter for each day, and just call the current day from the array as you go through each month day. That’s basically what our plugin does, only it is limited to one week. But that’s just the first of the hurdles you are going to face to build this customization.

    In this forum, in order to provide volunteer/free support to everyone we are only able to give basic overviews like the above for customizations. That said, sometimes one of the community volunteers has more time and can provide further assistance. So I will definitely leave this topic open in case someone comes along.

    Best of luck with your customization.
    – Brook

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘displaying the calendar horizontally’ is closed to new replies.