If you don’t register the CPT then index.php will be used, and if you only register the CPT for the backend, which is what is_admin
checks for, then index.php
will pretty much always be used.
In other words, you are only registering your CPT for the backend, not for the front. It isn’t ever going to work correctly that way.
What you are doing wrong is fundamentally misunderstanding the is_admin
function.
I think what you need is current_user_can
but you wouldn’t want to register the post type on that switch, or I don’t think you do. That will probably cause unwanted behavior as well, but of course you are welcome to try. Maybe something like…
function hide_cpt($content) {
global $post; // might not be necessary
if ('your-post-type-name' == $post->post_type && current_user_can('administrator')) {
return 'You can\'t look at this';
}
return $content;
}
add_filter('the_content','hide_cpt');
It is hard to say for sure if that will do what you want though. Your description isn’t heavy on detail.