Most of your code looks OK. But there is a major problem with your WP_Query in portfolio template. Your query looks like this:
<?php $query = new WP_Query( array( 'slug' => 'design' ) );?>
And if you take a look at WP_Query docs, you’ll see there is no parameter called slug
. So it’s pretty clear that it can’t work.
If you want to display portfolio
posts with given type
, then your query should look like this:
$query = new WP_Query( array(
'post_type' => 'portfolio',
'posts_per_page' => -1,
'tax_query' => array(
array( 'taxonomy' => 'type', 'field' => 'slug', 'terms' => 'design' ),
),
) );