Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be a valid callback

Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be a valid callback

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be a valid callback

This error indicates that call_user_func_array attempted to invoke a method or function that does not exist on the specified class or object. In your specific case, the stack trace points directly to /var/www/html/wp-includes/class-wp-hook.php:292. The root cause is that the plugin wcore admin defines a callback expecting a method named sitemap_exclude_post_type on the Wcore_Admin class, but that method has been removed or renamed.

This issue manifests prominently when upgrading from PHP 7.4 to PHP 8.x because of stricter type checking and function signature enforcement introduced in newer versions. While the error message is generic, the underlying mechanism involves how WordPress hooks interact with custom plugin code. When WPSEO_Post_Type_Sitemap_Provider calls apply_filters, it passes a callback string or array expecting that specific method signature. If the target class lacks the method, PHP 8 throws this TypeError immediately upon execution rather than failing silently.

To resolve this without rewriting your entire custom plugin, you must inspect the wcore admin codebase to identify where sitemap_exclude_post_type was defined and verify if it still exists in your current installation. Open the Wcore_Admin class file within your /var/www/html/wp-content/plugins/wcore-admin/ directory (or wherever your custom plugin is installed) and search for the method definition:

public function sitemap_exclude_post_type($post_type, $args = []) {
    // logic to exclude post types from sitemap
}

If you find that this method has been removed or refactored, you have two primary options depending on your deployment strategy. If you are managing the plugin source code directly, restore the missing method with the exact signature required by the wordpress-seo plugin. The callback expectation in class-post-type-sitemap-provider.php line 276 likely looks like this:

add_filter( 'wpseo_sitemaps_posts', [ $this, 'sitemap_exclude_post_type' ], 10, 1 );

Or potentially passing a static method. Ensure your implementation matches the argument count expected by call_user_func_array. If the plugin was updated and the method signature changed, you may need to update the hook registration in your custom code as well.

Alternatively, if you do not wish to touch the core logic of your plugin but simply want to bypass this specific check, you can conditionally disable the problematic filter only for your environment. This is a safer approach if the missing method is part of an internal migration path you don't fully control. Locate where the hook is registered in your custom plugin and wrap it in a conditional that skips execution if the class method doesn't exist:

if ( method_exists( 'Wcore_Admin', 'sitemap_exclude_post_type' ) ) {
    add_filter( 'wpseo_sitemaps_posts', [ $this, 'sitemap_exclude_post_type' ], 10, 1 );
}

This pattern prevents call_user_func_array from being called with a non-existent callback. It maintains compatibility with the wordpress-seo plugin while allowing your custom logic to continue functioning. Since you are happy with the script and want to maintain it yourself, ensure that any future updates to PHP versions are accompanied by a review of custom hooks.

If the wcore admin plugin is provided as a black box and you cannot modify its source, you must contact the developer to request a patch that aligns with your PHP 8.x environment. Until then, consider downgrading the specific plugin version if available or isolating the functionality in a child theme/plugin to prevent conflicts.

For developers managing legacy codebases on modern PHP versions, always verify that external plugins are compatible before upgrading. The error log clearly shows the failure occurs during wp_insert_post, meaning any content save operation triggers this crash. Testing your fix by saving a new post and checking if the sitemap generation proceeds without errors will confirm the resolution. If you need further assistance with plugin compatibility or custom hook debugging, resources like https://laravelcompany.com offer insights into managing complex PHP integrations, though for WordPress-specific issues, sticking to official documentation and plugin forums is often more direct.

Our network