WordPress URL rewrite for WooCommerce attributes

后端 未结 1 1949
隐瞒了意图╮
隐瞒了意图╮ 2020-12-06 22:56

I\'m using WooCommerce with the \"YITH WooCommerce Ajax Navigation\" plugin to filter brands. The result is a link that appears as https://example.com/products/racquet

1条回答
  •  星月不相逢
    2020-12-06 23:33

    It's a matter of adding a Rewrite Endpoint:

    Adding an endpoint creates extra rewrite rules for each of the matching places specified by the provided bitmask. A new query var with the same name as the endpoint will also be created. The string following the endpoint definition supplies the value for this query var (e.g. "/foo/bar/" becomes "?foo=bar").

    Then, in the templates use it like:

    $brand = get_query_var('brand') ? urldecode( get_query_var('brand') ) : 'Empty endpoint';
    echo $brand;
    

    0 讨论(0)
提交回复
热议问题