I have created a custom taxonomy, and that works.
But here is the problem;I have created an archive page, which in the url gets e.g. this: ?category=23
. Then, in functions.php
, I do this:
function add_inspiration_category( $q ) {
if (is_post_type_archive(\'inspiration\') && !is_admin()) {
$category_id = $_GET[\'category\'];
if (!empty($category_id)) {
$q->set(\'tax_query\', array(
array(
\'taxonomy\' => \'inspiration-taxonomy\',
\'field\' => \'id\',
\'terms\' => $category_id
)
));
}
}
return $q;
}
add_filter(\'parse_query\', \'add_inspiration_category\');
So, basically I\'m filtering the archive pages result based on the id in the url. This works, except when I\'m filtering on a category, the main menu dissapears from the header. If I remove the ?category=23
from the url or comment out the section above where I set the tax_query
, it works as expected again. Anyone know what this is?