Slugs Manager developer reference #
This reference documents the programmatic surface of Slugs Manager: Delete Old Permalinks from WordPress Database for developers: the meta key it operates on, its scheduled event, the custom cron intervals it registers, its load action, and the core methods you can call in your own code. Names below are taken from the plugin source (version 2.8.2).
The meta key #
Slugs Manager works entirely on the WordPress core post meta key _wp_old_slug. WordPress writes a row with this key whenever a published post’s slug changes, and uses it to 301-redirect the old URL to the current one. The plugin reads and deletes these rows; it does not touch term slugs (_wp_old_term_slug).
Core API #
The main instance is returned by alg_slugs_manager(), and its core object exposes two public methods:
| Method | Description |
|---|---|
alg_slugs_manager()->core->get_old_slugs() |
Returns all _wp_old_slug rows from the postmeta table, ordered by post ID. |
alg_slugs_manager()->core->delete_old_slugs( $post_ids = false ) |
Deletes _wp_old_slug rows. Pass an array of post IDs to scope the deletion, or omit the argument to delete all old slugs. |
// Delete all old slugs programmatically.
if ( function_exists( 'alg_slugs_manager' ) ) {
alg_slugs_manager()->core->delete_old_slugs();
}
// Delete old slugs for specific posts only.
alg_slugs_manager()->core->delete_old_slugs( array( 123, 456 ) );
Scheduled event #
When Scheduled Clean Ups is enabled (Pro), the plugin schedules the WP-Cron action alg_remove_old_slugs_cron at the chosen interval. Its callback calls delete_old_slugs() to remove all old slugs. You can hook the same event to run your own logic before or after a scheduled clean up:
add_action( 'alg_remove_old_slugs_cron', function () {
// Runs on each scheduled clean up.
} );
Custom cron intervals #
The plugin registers two custom schedules through the WordPress cron_schedules filter, in addition to the core intervals:
| Schedule key | Interval |
|---|---|
minutely |
60 seconds |
weekly |
604800 seconds (7 days) |
Load action #
After the plugin loads, it fires the action alg_slugs_manager_plugin_loaded, passing the plugin’s main file path. Use it to run code once Slugs Manager is available:
add_action( 'alg_slugs_manager_plugin_loaded', function ( $plugin_file ) {
// Slugs Manager is loaded and $plugin_file is its main file path.
} );
Notes #
- Deleting an old slug removes the WordPress redirect it provided. If you clear old slugs in code, handle redirects for any URLs that still receive traffic.
- Automatic Clean Ups and Regenerate Slugs are gated to the Pro version. The core methods above are available whenever the plugin (free or Pro) is active.
Need a hand? Our team answers every ticket on the Slugs Manager support forum.