1

我正在尝试将链接/网址添加到 Mixitup 插件过滤菜单,以便我可以从另一个页面链接到特定的过滤链接。我怎么做?根据我找到的那个教程(通过 url 过滤),这段代码应该可以工作

$( document ).ready(function() {
    var filterOnLoad = window.location.hash ? '.'+(window.location.hash).replace('#','') : 'all';
     $('#events-list').mixItUp({
         controls: {
            enable: true,
        },
        load: {
            filter: filterOnLoad,
        },
        animation: {
            // enable: false,
            // duration: 200,
            effects: 'fade',
        },
        layout: {
            display: 'inline-block',
        },
    });
});

但是我的过滤菜单不起作用。这是我在 wordpress 中的过滤菜单

<div class="filtermenu">
<ul id="filters">
    <li class="filter" data-filter="all" class="selected">All</li>
    <?php 
        $terms = get_terms('category', 'include=6,7&hide_empty=0'); // get all categories, but you can use any taxonomy
        $count = count($terms); //How many are they?
        if ( $count > 0 ){  //If there are more than 0 terms
            foreach ( $terms as $term ) {  //for each term:
                echo "<li class=".filter." data-filter='.".$term->slug."'>" . $term->name . "</li>\n";
                //create a list item with the current term slug for sorting, and name for label
            }
        } 
    ?>
</ul>
</div>

我尝试更改<li>to<a>并添加 href="#" 但由于它在<?php>标签中,所以它不起作用,我不知道为什么....

4

0 回答 0