I've solved it myself now, still not getting it 100% but it works at least.. There has got to be some smarter way of doing this, since im now looping trough all images for every term. Well, here's the code (get posts grouped by term from custom taxonomy).

&lt;section id="content"&gt;
&lt;?php
$categories = get_categories('taxonomy=year&amp;order=DESC');

foreach($categories as $category) { ?&gt;

    &lt;article class="year"&gt;
        &lt;h2&gt;&lt;?php echo $category-&gt;name ?&gt;&lt;/h2&gt;
        &lt;div class="items"&gt; 
        &lt;?php
        $args = array(
            'post_type' =&gt; 'portfolio'
        );

        query_posts($args);
        $count = 0;

        while(have_posts()) : the_post();
            $terms = get_the_terms( $post-&gt;ID, 'year' );

            foreach ( $terms as $term ) {
                $imgslug = $term-&gt;name;
            }

            if($imgslug == $category-&gt;name) {
                if($count == 6) {
                    echo '&lt;div class="expanded-items"&gt;';
                }
        ?&gt;
                &lt;div class="item"&gt;
                &lt;?php 
                $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
                echo '&lt;a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" rel="lightbox[' . $category-&gt;slug . ']" &gt;';
                the_post_thumbnail('thumbnail');
                echo '&lt;/a&gt;';
                ?&gt;
                &lt;/div&gt;

                &lt;?php 
            }
            $count++;

        endwhile;
        if($count &gt;= 6) {
            echo '&lt;/div&gt;';
        }
        ?&gt;                  
        &lt;/div&gt;
        &lt;div class="expand"&gt;Visa fler&lt;/div&gt;
    &lt;/article&gt;
&lt;?php } ?&gt;
&lt;/section&gt;


That is with an expandable list, so it shows 6 from the start and then expands to show the rest of the items (jQuery).

WordPress - Get posts in custom taxonomy category
In linux we just need to append a &amp; and that's all.

What for windows?
