Excluding custom post types

This function could help you filter out non standard post types:

function is_non_standard_type($id = null) {
    if (!$id) {
        // rewind_posts();
        global $post;
        $id = $post->ID;
    }
    $post_type = get_post_type( $id );

    return in_array($post_type, array('post', 'page', 'attachment', 'nav_menu, 'nav_menu_item', 'revision')); // You might want to handle revision differently
}

Keep in mind though that this is basically only true for single pages (i.e. is_single() === true), and even then you can’t be entirely certain. This is due to the fact that the global $post might change during the course of loading the page, depending on what happens during any loops. For example, a loop in a sidebar might overwrite the value of $post. To account for this you could use rewind_posts() to revert to the state the global query/post was in when the page started loading.

But then there are also archive pages, for which the $post variable might not hold anything or might not reflect a single post type. Take taxonomy pages for example – as they taxonomies are not unique to a single post type you can’t really be sure that just because you are querying taxonomy_x you will only get posts of type post_type_y. You might be able to work around this by using a function such as the below, but it will only work if the query being run has the post_type defined, which it might not always be.

function queried_post_type_object() {
    $var = get_query_var('post_type');

    if ($var) {
        return get_post_type_object($var);
    }

    return null;
}

Even if you do manage to correctly determine which post type, taxonomies etc. are being displayed, the logic involved will not be trivial. Finding the right combination of is_single(), is_archive() in combination with exception for different post types will probably pose a challenge, but with a bit of work you should be able to solve it.

error code: 523