Back to Community

Troubleshooting Common Custom Post Type UI Errors and Warnings

27 threads Sep 10, 2025 PluginCustom post type ui

Content

Custom Post Type UI (CPTUI) is a powerful tool for managing custom content in WordPress. However, users sometimes encounter PHP warnings, errors, or unexpected behavior. Based on common community reports, this guide explains the most frequent issues and how to resolve them.

Common Error: Invalid Argument Supplied for foreach()

This is one of the most prevalent warnings. It often appears as:
Warning: Invalid argument supplied for foreach() in .../wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 385

Why It Happens:

This warning typically occurs when the data structure for a post type or taxonomy saved by CPTUI becomes corrupted or is missing expected array data. For instance, a post type might be missing its 'labels' array, or the main post type data might not be an array when the plugin expects it to be.

How to Fix It:

  1. Re-save Your Post Types and Taxonomies: The most common fix is to navigate to CPT UI > Add/Edit Post Types and CPT UI > Add/Edit Taxonomies. Open each of your saved items, and simply click 'Save' without making any changes. This action can rebuild the proper data structure and clear the warning.
  2. Check for Corrupted Imports: If the issue started after importing settings from another site or a different plugin (like WCK), the imported data might be corrupted. You may need to manually remove the problematic entries from the database. CPTUI stores its settings in the wp_options table under the option names cptui_post_types and cptui_taxonomies. Warning: Only edit the database if you are comfortable and have a full backup.

Common Error: array_key_exists() Expects Parameter 2 to Be Array

This error, often seen in lines 878 or 1892 of CPTUI files, indicates the code is trying to check for a key in a variable that is not an array.

Why It Happens:

Similar to the foreach error, this suggests the underlying data for a post type is not formatted correctly. It could be a string instead of an array, which often happens if settings are corrupted.

How to Fix It:

  1. Re-save Settings: As with the first error, try re-saving your post types and taxonomies in the CPTUI admin screens.
  2. Update the Plugin: In one instance (Thread 21), the 'Custom Post Type UI' team fixed a specific version of this bug in v1.11.1. Always ensure you are running the latest version of the plugin.

Common Issue: Integration with Advanced Custom Fields (ACF)

Many threads report issues where ACF fields don't show data, don't display correctly (e.g., missing WYSIWYG toolbar), or seem to be out of sync.

Why It Happens:

CPTUI and ACF are separate plugins. CPTUI handles the registration of the post type, while ACF handles attaching and displaying custom fields. These issues are rarely caused by CPTUI itself but often by:

  • Javascript conflicts from other plugins or the theme.
  • The 'Disable the visual editor' setting being checked in the user's profile.
  • The load order of plugins. If ACF loads after CPTUI, it might not associate fields correctly in some complex setups.
  • Custom code in the theme's functions.php file that interferes with ACF (as was the solution in Thread 10).

How to Fix It:

  1. Basic Troubleshooting: First, check your user profile to ensure the visual editor is enabled. Then, follow standard conflict testing procedures: switch to a default WordPress theme (like Twenty Twenty-One) and disable all other plugins except CPTUI and ACF. If the problem goes away, re-enable themes and plugins one by one to find the conflict.
  2. Adjust Load Order (Advanced): If you suspect a load order issue, you can try forcing CPTUI to register its post types later, after ACF has likely loaded. You can add this code to your theme's functions.php file:
    remove_action( 'init', 'cptui_create_custom_post_types', 10 );
    add_action( 'init', 'cptui_create_custom_post_types', 11 );
  3. Contact ACF Support: Since the issue usually lies outside of CPTUI's functionality, the ACF support team is often best equipped to help diagnose field-specific problems.

When an Error is Probably Not From CPTUI

It's important to read error messages carefully. Errors that mention files from other plugins, like js_composer_salient (Visual Composer) or post-my-cf7-form, are not caused by CPTUI. For these, you should deactivate CPTUI to confirm, and then seek support from the plugin mentioned in the error message's file path.

Conclusion

Most common CPTUI errors relate to data corruption and can be fixed by re-saving settings. For integration issues with other plugins like ACF, systematic conflict testing is key. Remember, the 'Custom Post Type UI' plugin is solely responsible for registering post types and taxonomies; it does not control how other plugins like ACF or page builders display content on the front end.

Related Support Threads Support