我有一个问题,我忙着在wordpress中使用过滤器。现在我有问题,我试着解释一下。
如果访客选择"单一的方式" url将是?merk = Brand1而不是选项2是select" Soort"而网址将是"?merk = Brand1& soort = Soort1"这很有效。
但如果你选择了两者,那么只想改变?merk = Brand2而不是url是"?merk = Brand2& soort = Soort1& merk = brand1"如果你在" merk"之间切换,我该怎么做呢? " Brand1"替换为" Brand2"。
以下是代码:
foreach ( $allemerken as $merksingle ) { ?>
<?php if(isset($_GET['merk']) && $_GET['merk'] == $merksingle->slug){?>
<a href="<?php echo $current_url; ?>" class="filter_merklink active"><i class="fa fa-times" aria-hidden="true"></i> <?php echo $merksingle->name; ?></a>
<?php }else{ ?>
<a href="<?php echo $current_url; ?>?merk=<?php echo $merksingle->slug;?><?php if(isset($_GET['soort']) && $_GET['soort'] != ''){ echo '&'.$_SERVER['QUERY_STRING'];} ?>" class="filter_merklink"><?php echo $merksingle->name; ?></a>
<?php }?>
<?php }?>
<p class="mt-30"><strong>Soort:</strong></p>
<?php
$soorten = get_terms('warmtepompcategorie');
// echo '<pre>'.print_r($allemerken,true).'</pre>';
foreach ( $soorten as $soort ) { ?>
<?php if(isset($_GET['soort']) && $_GET['soort'] == $soort->slug){?>
<a href="<?php echo $current_url; ?>" class="filter_merklink active"><i class="fa fa-times" aria-hidden="true"></i> <?php echo $soort->name; ?></a>
<?php }else{ ?>
<a href="<?php echo $current_url; ?>?soort=<?php echo $soort->slug;?><?php if(isset($_GET['merk']) && $_GET['merk'] != ''){ echo '&'.$_SERVER['QUERY_STRING'];} ?>" class="filter_merklink"><?php echo $soort->name; ?></a>
<?php }?>
<?php }?>
聚苯乙烯。抱歉我的英语不好,但希望有人可以帮帮我!
答案 0 :(得分:0)
为防止值重复,我会在$(document).blur( function () {
var video = Wistia.api("video1");
video.pause();
});
数组或其副本上运行,以添加或删除参数,如:
$_GET
然后使用http_build_query()构建URL编码的查询字符串,如下所示:
$_GET['soort'] = 'new value'; // adding, modifying value
unset($_GET['soort']); // removing value
答案 1 :(得分:0)
我做了一个功能。 我这样做了:
function replace_get($newname,$newvalue){
$oldvars = $_GET;
$varsnew = $newname.'='.$newvalue;
foreach($oldvars as $name=> $value){
if($name != $newname){
$varsnew .= '&'.$name.'='.$value;
}
}
return $varsnew;
}