Filtering a Collection in WordPress

I’m helping a client with a pre-existing WordPress portfolio site. The site uses the GT3-Pure theme.

Here is the page in question: http://rachelkashon.com/projects/

I am having an issue on the portfolio (collection) pages with the category links across the top. If the category name contains any spaces, the filter doesn’t work. If I replace any spaces in the category name with a character (a dash for instance) it works fine.

If you look at the page linked above, you’ll notice that ‘Event-Design’ works, while ‘In Store’ does not.

Obviously the space is the problem. It looks like the code is trying to use the category slug as the filter, which would be optimal in my opinion. But (isset($GET[‘slug’])) (which is part of the theme code) returns false, even though I have given each category a slug within Wordpress.

Here is the code that generates the list:

[code]if (!function_exists(‘showPortCats’)) {
function showPortCats($post_type_terms = “”)
{
if (!isset($term_list)) {
$term_list = ‘’;
}
$permalink = get_permalink();
$args = array(‘taxonomy’ => ‘Category’, ‘include’ => $post_type_terms);
$terms = get_terms(‘portcat’, $args);
$count = count($terms);
$i = 0;
$iterm = 1;

if ($count > 0) {
    if (!isset($_GET['slug'])){
        $all_current = 'selected';
    }
    $cape_list = '';
    $term_list .= '
    <li class="grid_masonry_view"></li>
    <li class="inline_view"></li>
    <li class="' . $all_current . '"><a data-option-value="*" href="#filter">' . __('All', 'gt3_builder') . '</a></li>
    ';
    $termcount = count($terms) ;
    if (is_array($terms)) {
        foreach ($terms as $term) {
            $i++;
            $permalink = add_query_arg("slug", $term->slug, $permalink);
            $term_list .= '<li ';
            if (isset($_GET['slug'])) {
                $getslug = $_GET['slug'];

            } else {
                $getslug = '';
            }
            if (strnatcasecmp($getslug, $term->name) == 0){

                $term_list .= 'class="selected"';
            }

            $tempname = strtr($term->name, array(
                ' ' => '-',
            ));
            $tempname = strtolower($tempname);

            $term_list .= '><a href="#filter" data-option-value=".' . $tempname . '" title="View all post filed under ">' . $term->name . '</a>
        </li>';
            if ($count != $i) $term_list .= ' '; else $term_list .= '';
            $iterm++;
        }
    }
    return '<ul class="optionset" data-option-key="filter">' . $term_list . '</ul>';
}

}
} [/code]
And the JQuery:

jQuery(".optionset").on( "click", "li a", function() { var filterValue = jQuery(this).attr("data-option-value"); jQuery(".optionset li").removeClass("selected"); jQuery(this).parent().addClass("selected"); $container.isotope({ filter: filterValue }); });
Ideas?

I’m not completely following, but the space issue is usually a matter of encoding and decoding spaces as %20

Sponsor our Newsletter | Privacy Policy | Terms of Service