I\'m trying to add a URL GET parameter to one of my main menu items in Wordpress(but I don\'t know how to). So, my approach was to detect a click event on the menu item, the
The problem is that you are attempting to pass a boolean value in your Ajax call with the variable homeclick. GET requests simply use text because the data is passed thru the URL, so if you are wanting a logical/boolean type you can use either "true" and "false" in text or perhaps 0 and 1. Also you have a syntax error, see below.
Try the following:
In you ajax call, fix the syntax as well as set homeclick to "true" as follows:
data: ({ homeclick: 'true' }),.
And in your php, change the if condition for variable $homeclick as follows:
$homeclick == 'true'.
You may want to consider using a POST method if you want to utilize a boolean.