Is it possible to hide nav menu items only when they are page titles (on specific templates) but not on the dashboard?

You can use is_admin() to check if the request is done being inside /wp-admin.

function suppressed_title($title, $id) {
    if (is_admin()) {
        return $title;
    }
    if (get_page_template_slug() === 'custom-template.php' && get_post_type($id) === 'page') {
        $title="";
    }
    return $title;
}
add_filter('the_title', 'suppressed_title', 10, 2);

I changed your code to use triple equals === over == as this is usually considered best practice. (See this StackOverflow answer for more info.)


I want to hide the page titles that use a custom page template

Technically, you’re not hiding the title right now, but displaying an empty title. This might have effects on the styling anyway. In my opinion a cleaner solution would be not to display the title at all at these pages. But this is highly dependent on which theme you are using.