Replies: 0
While checking the code of a plugin which creates a custom post I am seeing the developer checking if the request is for the backend using is_admin() and then including the file to register the custom post type and custom field .
// Check if admin
if(is_admin()){
// Load Custom Post Type
require_once(plugin_dir_path(__FILE__) . '/includes/my-todo-list-cpt.php');
// Load Custom Fields
require_once(plugin_dir_path(__FILE__) . '/includes/my-todo-list-fields.php');
}
All this while I creatingwas create custom posts /fields without using is_admin() without any problem . The custom post/fields do not show in the front end if I do not check using is_admin() . Could you anybody tell me whats the benefit of using is_admin() while creating a custom post ? Is it a normal practise specially in production code to code like above ?