Site icon Hip-Hop Website Design and Development

Post in multiple categories do not include in previous / next post if one category in excluded

I have read the following post which appears to solve my problem but doesn’t…

excluded_categories parameter in next_post_link() behaving unexpectedly

I have posts in say 3 categories but if they are included in category ‘update’ (which is ID 96) I would like them excluded from the previous / next navigation system. From the above post I have edited the following code (this is all in my functions.php file as the single.php template calls for the navigation from there).

<?php previous_post_link( '<li class="previous">%link</li>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'reboot' ) . '</span> %title', FALSE, prev_next_dont_include( array( 96 ) ) ); ?>

and added the following code…

function prev_next_dont_include( $ids ) {
foreach ( get_categories() as $category ) : // loop thru all WP cats
    if ( !in_array( $category->cat_ID, $ids ) ) : // check if cat id is in $ids
        $categories[] = $category->cat_ID; // build list of real excluded ids
    endif;
endforeach; 
return implode( ' and ', $categories ); // "1 and 2 and 5 and 7 and 16 and 23"
}

Now when I go to my navigation, instead of excluding category 96 it only includes all posts within category 96 – the posts could also be included in other categories also. It excludes all posts not in category 96? Can anyone assist?