How can I fix those issues generated by the Themecheck plugin

I’ve got the following error messages on the themecheck plugin in my WordPress theme.

REQUIRED: The theme uses the register_taxonomy() function, which is plugin-territory functionality.
REQUIRED: The theme uses the register_post_type() function, which is plugin-territory functionality.
WARNING: The theme uses the add_shortcode() function. Custom post-content shortcodes are plugin-territory functionality.

I declared the register_taxonomy() and register_post_type() function in after_setup_theme hook.
My register_taxonomy() function is:

register_taxonomy('project_cat', 'project', array(
    'public'        => true,
    'hierarchical'  => true,
    'labels'        => array(
        'name'  => 'Categories',
    )
));

And one of my register_post_type() function is:

register_post_type('service', array(
    'public'    => true,
    'supports'  => array('title', 'thumbnail', 'editor'),
    'labels'    => array(
        'name'          => esc_html__('Services', 'textdomain'),
        'add_new_item'  => esc_html__('Add Service', 'textdomain'),
        'add_new'       => esc_html__('Add Service', 'textdomain')
    )
));

How can I fix those issues?

2 Answers
2

Registering custom posts is a plugin territory. It means that you need to remove them from the theme’s functionality and register them via a plugin (usually recommended when installing the theme using TGM Plugin Activation or something else). Here are the recommendations of the Theme Review Team.

Themes must not incorporate the following, Plugin-territory
functionality. This list is not all-inclusive.

  • Analytics scripts
  • SEO options (meta tags, page title, post titles, robots.txt, etc.)
  • Content Sharing buttons/links
  • Custom post-content shortcodes
  • Custom Post Types
  • Custom Taxonomies
  • Removing or modifying non-presentational core hooks
  • Disabling the admin toolbar
  • Resource compression/caching

Leave a Comment