我想做什么 我需要为部落事件Wordpress插件构建一个“月栏”。我将“ bar.php”复制到主题文件夹,并设法在列表视图中搜索栏的顶部显示了未来12个月的列表。
我到目前为止所做的事情 我将链接添加到月份栏,并设法将月份作为查询添加到当前域(&tribe-bar-date = $ title),这使我进入正确的页面。到目前为止,一切都很好。
我的问题 在我的月栏链接上再按一下,就会向 current 域的末尾(&tribe-bar-date = 2018-12&tribe-bar-date = 2019-07)进行更多查询。我需要的是一个包含查询(&tribe-bar-date = $ title)的变量,并且在每个页面上都有一种刷新。
到目前为止,我的代码:
<div><!--horizontal bar test-->
<?php
// find out the domain:
$domain = $_SERVER['HTTP_HOST'];
// find out the path to the current file:
$path = $_SERVER['SCRIPT_NAME'];
// find out the QueryString:
$queryString = $_SERVER['QUERY_STRING'];
// put it all together - different ways:
//$url = "https://" . $domain . $path . "?" . $queryString;
// An alternative way is to use REQUEST_URI instead of both
// SCRIPT_NAME and QUERY_STRING, if you don't need them seperate:
$url = "http://" . $domain . $_SERVER['REQUEST_URI'];
//echo $url;
//END find out the domain
//Venue ID - just in case.
$post_id = get_the_ID();
$v1 = '8995';
$v2 = '1444';
$venue = tribe_get_venue();
//END Venue ID - just in case.
// Month bar starts here
echo "<p class=’text-center no-underline’ style=’margin-top: 20px;’>Month: ";
for ( $i = 0; $i <= 12 ; $i++ )
{
$next = date('Y-m',strtotime("+$i months"));
$m = date('M',strtotime("+$i months"));
$title = date('Y-m',strtotime("+$i months"));
//echo "<a href='$url&tribe_bar_date=$title'>$m</a>";
echo "<a href='$url&tribe-bar-date=$title'>$m</a>";
}
echo "</p>";
?>
<!-- end horizontal bar--></div>