Click here to Skip to main content
14,211,795 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi I have a wordpress site that needs a simple appointment booking section. Everything is working fine but I want to exclude Sundays from the calendar. This is the page with the booking: http://fluffypuppies.ca/1317-2/ The person should not be able to select Sundays and it should be greyed out.

I found this code but I don’t know where it should go. I tried placing it in the functions.php but I get an error message. Where should it go in order to make it work correctly? Or if you have a better suggestion I’d appreciate it.
Thanks



function DisableSunday(date) {

var day = date.getDay();
// If day == 0 then it is Sunday
if (day == 0) {

return [false] ;

} else {

return [true] ;
}

}

$(function() {
$( "#datepicker" ).datepicker({
beforeShowDay: DisableSunday
});
});


What I have tried:

I have tried removing the script tag, also placing it directly in the module within my wordpress theme. I have also tried removing the first $ sign and replacing it with jQuery(function($). I know I'm close, but what am I missing?!
Posted
Updated 24-May-18 15:17pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I would suggest not to modify the core files, because the update might overwrite it. Usually I use the Wordpress Header and Footer plugin. After you install it, Activate it, and you can place the scripts in the header or footer. The plugin can be accessed from the Settings menu. Will the above script going to work is another story because I'm not sure how your application being structure. Look like it will work if there a datepicker with the id "#datepicker" on the page.


Head, Footer and Post Injections — WordPress Plugins[^]
   
Comments
Member 13843527 24-May-18 22:02pm
   
Ok Bryan, I'll try that right now. I'm using a child theme so as not to lose anything with updates. I think the Divi theme I'm using provides for header and footer code.
Thanks
Member 13843527 24-May-18 22:31pm
   
My theme had header and footer plugin already built in. I tried the code in all the positions but no luck. Anything else you can suggest? Really, really appreciate your help. I'm so close! Arrgh!!
Bryian Tan 24-May-18 22:56pm
   
Look like your code is fine. I would make sure the "#datepicker" id exists in the context.

Bug DatePicker jQuery-UI - Plunker[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190619.2 | Last Updated 24 May 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100