So im using isotope to filter categories on my blog page, when you click on a blog I still have my menu of categories at the top of the single blog post so people can click on a category and it will take them back to the blog page but on the category selected. So on the single blog page ive added an add_query_arg to the link to return a custom url.
<a href="<?php echo add_query_arg( 'cat', $category->name, '/blog' );?>">
this gives me the url on my blog page as mysite.com/blog/?cat=information
then on my blog page i call the query like this
<?php $cat = get_query_var('cat');?>
Then in my javascript for filtering the categories with isotope i have
filter: "<?php echo $cat;?>"
but this is not returning anything in my javascript when i view source is just
filter: ""
i have also added this to my functions.php
function add_query_vars_filter( $vars ){
$vars[] = "cat";
return $vars;
}
//Add custom query vars
add_filter( 'query_vars', 'add_query_vars_filter' );
anyone got an idea where im going wrong?