Appointment + selecting weekly/monthly scheduler


Just wanted to check if there is a 'hook' we could use to provide our client with an option to select a weekly schedule from a calendar or dropdown so we can take the selected date and insert into the [app_monthly_schedule date="yyyy-mm-dd"] shortcode from the functions.php file?

The main reason we wish to offer this is because we currently have the appointment page setup for a weekly scheduler due to the high number of Services and that appointments can be made up one year ahead. We had to select the weekly scheduler because the response times are slow if set to monthly.

The client wishes to be able to 'jump' straight to a particular week instead of having to click 'next' until the particular week is reached.

We have tried loading more than one weekly schedule on the page so clicking the 'next' button jumps more than one week but loading times are increased and we don't want to show more than one week at a time.

Could the above be integrated into the pagination so instead of being presented with a 'previous'/'next' button there is a dropdown with an option to 'jump' straight to a selected week?

Is either option possible and if so could you provide the bespoke code we would need to add to the functions.php file?

If you require any further info please let me know


  • pxwm

    Hi @Alexander Rohmann

    Many thanks for the prompt response.

    I was hoping we could have a dropdown with selectable start dates for each week or month taking into account the shortcode rule that can be used to determine the start date/day of the week/month.
    And then using this selected Start date to be used as the parameter in the shortcode [app_monthly_schedule date="yyyy-mm-dd"]

    I appreciate the shortcode is contained within the appointment page so I'm not sure if this is feasible because normally Wordpress will not allow 'live' changes to be inserted in a page because of the risk for 'hacking'

    However I was hoping we could use a 'hook' in the functions.php file


  • Vladislav


    The prev/next links work by passing an UNIX timestamp as GET variable named "wcalendar". This UNIX timestamp will be used to render a displayed period (month or week) that has this date enclosed somewhere within.

    Having this in mind, it's relatively simple to generate a selection list with future dates for, say, next year, that will act as a drop-down pager. Here's a quick sample code, which is almost exclusively javascript-based:

    function app_add_week_paging () {
    	echo '<div id="app-date_paging_selection"></div>';
    ;(function ($) {
    $(function () {
    	var root = $("#app-date_paging_selection"),
    		now = new Date(),
    		now_ts = now.getTime(),
    		next_year_ts = (new Date).setFullYear(now.getFullYear() + 1)
    		sel = ''
    	while (now_ts < next_year_ts) {
    		var date = now.getDate(),
    			opt = parseInt(now_ts/1000,10)
    		sel += '<option value="' + opt + '">' + now.getFullYear() + '-' + (now.getMonth()+1) + '-' + now.getDate() + '</option>';
    		now_ts = now.getTime();
    		.append('<select>' + sel + '</select>')
    		.find('select').on('change', function () {
    			var ts = $(this).val(); = 'wcalendar=' + ts;
    			return false;
    add_action('wp_footer', 'app_add_week_paging');

    This will add the dropdown list in your footer. Of course, this is just a very quick sample, it can be improved in myriads of ways, but hopefully it can get you started in the right direction. Unfortunately, the app_pagination shortcode isn't filtered but with a bit more JS you can swap the prev/next buttons for the drop-down selection generated in a similar manner.

  • pxwm

    Hi @Vladislav

    Excellent, many thanks and I'll try this out.

    Just out of interest we are still using v1.2.8 for our client as it is a live site and we are still finalising testing of v1.3.1 before upgrading.

    Just want to check if your solution would work using v1.2.8?

    Also not sure if you can recall we posted some months back a topic on response times and you did indicate that you were looking at optimising the code and the following refers:

    We are also considering upgrading the hosting to a Virtual Server but in the interim to improve performance for our client we temporarily changed the schedule from Monthly to Weekly and the performance times are acceptable even though there are 200+ services and appointments can be made up to 365 days ahead.

    I was just checking if you managed to improved response times in v1.3.1 so when we upgrade we can consider reverting back to a Monthly calendar and we could then even consider displaying two Monthly calendars on the same Appointment page so the client could jump two months ahead by just selecting the 'next' button.


  • Vladislav


    The "wcalendar" GET variable part (which is pretty much the basis of what we're doing in the code above) didn't change between versions, so this should work with v1.2.8 just as well.

    As for the processing times, I did some code profiling for v1.3 release and did managed to shave them off a bit. The caching used for this by default lasts one request - caching it longer with a persistent caching setup in place (once everything is set up, of course) should improve the performance even more.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.