0

我一直在努力解决这个功能,我希望我有足够的尊重来提供赏金。帮助将不胜感激。

// Advanced Search Check
function ct_search_form_check($name, $taxonomy_name = null) {
global $search_values;

    if (!$taxonomy_name) {
        $taxonomy_name = $name;
    } ?>
    <?php foreach( get_terms($taxonomy_name, 'hide_empty=0') as $t) : ?>
        <?php if ($search_values[$name] == $t->slug) { $selected = 'checked="checked"'; } else { $selected = ''; } ?>
            <div><input id="ct_<?php echo $name; ?>" name="ct_<?php echo $name; ?>" type="checkbox" style="margin-right:5px; margin-left:5px" <?php echo $selected; ?>value="<?php echo $t->slug; ?>"><?php echo $t->name; ?><span style="margin-left:10px"></span></input></div>

           //recently added this part to replace duplicate taxonomy_name in url
           <?php $data = array();
                while (list($name, $t->slug) = each($arr)) {
                   $data[] = "$name";
                }
                echo implode($data); ?>

    <?php endforeach; ?>

<?php
}

如何更改我的输出

?ct_zipcode=&ct_event_type=校友&ct_=anneverisy&​​ct_setting=ballroom&ct_=酒吧&场地搜索=true

?ct_zipcode=&ct_event_type=alumni%2canneverisy&​​ct_setting=ballroom%2cbar&Venue-search=true

4

1 回答 1

0

这行得通。希望它会帮助别人

function ct_search_form_check($name, $taxonomy_name = null) {
global $search_values;

    if (!$taxonomy_name) {
        $taxonomy_name = $name;
    } ?>

<input type="hidden" value=""  name="ct_<?php echo $name; ?>" />
    <?php foreach( get_terms($taxonomy_name, 'hide_empty=0') as $t) : ?>
        <?php if ($search_values[$name] == $t->slug) { $selected = 'checked="checked"'; } else { $selected = ''; } ?>
            <div><input id="ct_<?php echo $name; ?>" name="ct_<?php echo $name; ?>" type="checkbox" style="margin-right:5px; margin-left:5px" <?php echo $selected; ?>value="<?php echo $t->slug; ?>"><?php echo $t->name; ?><span style="margin-left:10px"></span></input></div>
           <?php 
           $data = array();
                while (list($name, $t->slug) = each($arr)) {
                   $data[] = "$name";
                }
                echo implode($data); 
                if (!empty($_GET['ct_'])) { 
                    $url = str_replace('&ct_=', '%2c', $_SERVER['QUERY_STRING']);
                    header("Location: ?$url");
                } ?>
    <?php endforeach; ?>
<?php 
} 
于 2013-03-03T06:26:08.047 回答