最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Add more than one query parameter onto wordpress url

programmeradmin1浏览0评论

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.">&#8678 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.">&#8678 Previous Month</a></div>";

(only modification = year query parameter changed to string 'hi').

发布评论

评论列表(0)

  1. 暂无评论