What I want to do I need to build a "month-bar" for tribe-events Wordpress plugin. I copied "bar.php" to my theme folder and managed to show a list of the next 12 months there, on top of the search bar in list view.
What I did so far I added links to the month bar, and managed to add the month as a query to the current domain (&tribe-bar-date=$title) which gets me to the correct page. So far so good.
My problem Every further klick on my month-bar links, ads more querys to the end of the current domain (&tribe-bar-date=2018-12&tribe-bar-date=2019-07). What I need is a variable which contains the query (&tribe-bar-date=$title), and gets a kind of refresh on every page.
My Code so far:
<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>
Monat: "; 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 "$m"; $query = $url; get_query_var('tribe-bar-date'); $new_query = add_query_arg( array( 'tribe-bar-date' => $title, ), $query ); echo " $m "; } echo "
";' – s.Panse Nov 14 '18 at 10:50