Override custom post types

Change the registration arguments of affiliate-toolkit post types (products, lists, shops, templates) with WordPress filters. Hooks, defaults, examples.

affiliate-toolkit stores products, lists, shops, templates and a few other objects as WordPress custom post types. Right before each type is registered, the plugin passes the registration arguments through a filter. With that filter you can change labels, menu settings, editor features or visibility without touching the plugin files, so your changes survive every update.

You need a child theme or a small site-specific plugin for the code. Add the filters in functions.php or in your plugin file; both are loaded before WordPress registers the post types on init.

Available filters

Every filter receives the array that is passed to register_post_type() and must return it.

FilterPost typeProvided by
atkp_product_register_post_typeatkp_product (products)Base plugin
atkp_list_register_post_typeatkp_list (lists)Base plugin
atkp_shop_register_post_typeatkp_shop (shops)Base plugin
atkp_template_register_post_typeatkp_template (templates)Base plugin
atkp_fieldgroup_register_post_typeatkp_fieldgroup (field groups)Custom Fields module
atkp_importset_register_post_typeatkp_importset (import sets)Import Sets module
ParameterTypeDescription
$argsarrayThe registration arguments (labels, public, show_ui, supports, rewrite, menu_position, show_in_menu …).
Return valuearrayThe modified arguments. Always return the array, otherwise the post type is registered without arguments.

The redirect post type of the Influencer module (atkp_redirect) has no filter.

Example: adjust the product post type

This snippet removes the product archive and adds the excerpt field to the product editor. If the Frontend Product Pages module is active, it registers its own callback on the same filter with priority 10. Use a higher priority such as 20 so your values are applied last.

/**
 * Product post type: no archive page, excerpt field in the editor.
 * Priority 20 runs after the Frontend Product Pages module (priority 10).
 */
function my_atkp_product_post_type( $args ) {
    $args['has_archive'] = false;
    $args['supports'][]  = 'excerpt';

    return $args;
}
add_filter( 'atkp_product_register_post_type', 'my_atkp_product_post_type', 20 );

The same pattern works for every post type. Here the menu label of the lists is renamed:

function my_atkp_list_post_type( $args ) {
    $args['labels']['menu_name'] = 'Product lists';
    $args['description']         = 'Product lists for our reviews';

    return $args;
}
add_filter( 'atkp_list_register_post_type', 'my_atkp_list_post_type' );

Default settings

These are the defaults you start from, taken from the plugin source. Only change what you need.

Post typeDefaults
atkp_productNot public, no archive, no rewrite rules; editor supports title and author (plus thumbnail depending on your settings). Shown in the affiliate-toolkit menu.
atkp_product with Frontend Product PagesThe module sets public, has_archive and the rewrite slug from its settings and adds editor, thumbnail and (optionally) comments.
atkp_listNot public, no archive, no rewrite rules; supports title only.
atkp_shopNot public, hierarchical (sub-shops), capability type page; supports title only.
atkp_templateNot public, own capability type atkp_template, not shown as a separate menu entry.
atkp_fieldgroupNot public, capability type page; supports title only.
atkp_importsetNot public, no rewrite rules; supports title only.

Notes

Do not change the post type name and keep show_ui and show_in_menu unless you really want to hide the screens. If you change rewrite, public or has_archive, save the permalinks once (Settings → Permalinks → Save Changes) so WordPress rebuilds its rewrite rules.

Changes take effect on the next page load. If a snippet breaks the admin, remove it from functions.php via FTP or the file manager of your host.