Dev: override the post types of the plugin

Reference: the filters that let you change the register_post_type() arguments of affiliate-toolkit products, lists, shops, templates and more.

affiliate-toolkit stores its data as WordPress post types. Right before each one is registered, the plugin passes the arguments for register_post_type() through a filter. Use these filters when you want to change labels, menu placement, editor features or visibility – without editing plugin files, so your change survives updates.

Put the code into a small site-specific plugin or the functions.php of a child theme.

Available filters

FilterPost typeProvided by
atkp_product_register_post_typeatkp_product – productsBase plugin
atkp_list_register_post_typeatkp_list – listsBase plugin
atkp_shop_register_post_typeatkp_shop – shopsBase plugin
atkp_template_register_post_typeatkp_template – templatesBase plugin
atkp_fieldgroup_register_post_typeatkp_fieldgroup – field groupsCustom Fields module
atkp_importset_register_post_typeatkp_importset – import setsImport Sets module
ParameterTypeDescription
$argsarrayThe arguments for register_post_type(): labels, public, show_ui, show_in_menu, supports, rewrite, has_archive …
Return valuearrayThe modified arguments. Always return the array.

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

Example

The basic pattern is the same for every post type:

/**
 * Called right before register_post_type() for the given post type.
 *
 * @param array $args The arguments passed to register_post_type().
 * @return array      The (modified) arguments.
 */
function my_atkp_product_post_type( $args ) {
    $args['description'] = 'My description';
    return $args;
}
add_filter( 'atkp_product_register_post_type', 'my_atkp_product_post_type', 20 );

With a loop you can change several post types at once, for example to remove them from the menu editor:

foreach ( array( 'product', 'list', 'shop', 'template' ) as $type ) {
    add_filter( "atkp_{$type}_register_post_type", function ( $args ) {
        $args['show_in_nav_menus'] = false;
        return $args;
    }, 20 );
}

The Frontend Product Pages module uses atkp_product_register_post_type itself (priority 10) to make products public and set the URL slug. Register your callback with a higher priority such as 20 so your values win.

Notes

  • Do not change the post type name, and keep show_ui, otherwise the edit screens of the plugin disappear.
  • After changing public, rewrite or has_archive, open Settings → Permalinks and save once so WordPress rebuilds its rewrite rules.
  • The default values of each post type are listed in Override custom post types.