Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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[^]
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900