As soon as someone clicks on an anchor tag in my website, I was planning to redirect to the same page containing the information added via two URL query parameters, and then access them with the $_GET superglobal, as it's usually done. I'm doing this in wordpress.
Now, I'm following exactly the instructions explained here /, meaning that I added the two parameters via the add_query_arg() wp function. The link is built perfectly, but the site is not recognized! (404 error produced). If I do exactly the same but with only one parameter (using the exact same syntax), it reloads the same page with the query parameter in the link, so with only parameter, wordpress recognizes the page perfectly. Anyone with the same problem ?? No comma or other syntax problems.
$previousMonth = date("m",mktime(0,0,0,$month-1,1,$year));
$previousYear = date("Y",mktime(0,0,0,$month-1,1,$year));
$previousLink = add_query_arg(
array(
'month' => $previousMonth,
'year' => $previousYear
)
);
$calendar .= "<div class='move-dates'><a class='move-calendar' href=".$previousLink.">⇦ Previous Month</a></div>";
This does not work (404 Error page, however with both query parameters correctly displayed in the correct URL; ?month=valuemonth&year=valueyear).. However, interestingly, this works:
$previousMonth = date("m",mktime(0,0,0,$month-1,1,$year));
$previousYear = date("Y",mktime(0,0,0,$month-1,1,$year));
$previousLink = add_query_arg(
array(
'month' => $previousMonth,
'year' => 'hi'
)
);
$calendar .= "<div class='move-dates'><a class='move-calendar' href=".$previousLink.">⇦ Previous Month</a></div>";
(only modification = year query parameter changed to string 'hi').