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?

Topic next-post-link previous-post-link navigation categories Wordpress

Category Web


Not sure it's strictly the answer but I found a plug-in which still meant I needed to edit my functions.php file and was probably overkill for what I wanted but it resolved the issue and I binned the code above completely.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.