I am developing a custom post type which shows releated posts which are within the category which is working perfect but I cant seem to get the right query to make it not show the current post which is being viewed.
The code I have at present is:
$args = array( 'post_type' => 'custompostname', 'tax_query' => array( array( 'taxonomy' => 'custompostname-categories', 'field' => 'id', 'terms' => $categoryIDs ) ), 'post__not_in' => $post->ID, 'posts_per_page' => 20 ); $q = new WP_Query($args);
Could anyone please shed some light on why this is not working.
If I remove the:
'post__not_in' => $post->ID,
It works apart from it shows the post which is on the page already