List More Custom Field Names

Beskrivelse

By default, WordPress only allows 30 custom field names/keys to be listed in the dropdown selection ‘Name’ field when writing a post or page. If you, or the plugins you use, make use of a lot of custom field key names, you may surpass the default limit resulting in some custom field keys not being listed. This may force post authors to manually type in custom field key names if they aren’t listed, which increases the chances for naming errors (typos, or not using the precise key name that is needed). This may also cause some authors concern wondering where previously used custom field keys have gone since they aren’t listed.

This plugin increases the limit to 200 custom field key names.

There is no settings page to customize the default value. If you’d like to list some number of custom field key names other than 200 (say, for example, 100), you can do so in either of two ways:

  1. By editing your wp-config.php file and at the end adding a line such as:
    define( ‘CUSTOM_FIELD_NAMES_LIMIT’, 100 );
    -or-
  2. Somewhere — ideally in a mu-plugin or site-specific plugin, or less ideally your active theme’s functions.php file — hook the ‘c2c_list_more_custom_field_names’ filter and return the number you’d like to use:
    add_filter( ‘c2c_list_more_custom_field_names’, function ( $limist ) { return 100; } );

Note: This plugin has no effect for users who make use of the block editor (aka Gutenberg) introduced in WordPress v5.0 because that editor does not directly expose custom fields in the interface.

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

Installasjon

  1. Install via the built-in WordPress plugin installer. Or download and unzip list-more-custom-field-names.zip inside the plugins directory for your site (typically wp-content/plugins/)
  2. Activate the plugin through the ‘Plugins’ admin menu in WordPress
  3. (Optional) In wp-config.php, customize the number of custom fields you want shown. The default of 200 can be changed by adding a line like:
    define( ‘CUSTOM_FIELD_NAMES_LIMIT’, 100 );

FAQ

What is the default number of custom field names/keys that WordPress lists in the admin when writing/editing pages and posts?

WordPress only lists up to 30.

How many custom field names/keys does this plugin list in the admin when writing/editing pages and posts?

By default, this plugin lists up to 200. You can customize this value.

How can I customize the default number of custom field name/keys listed in the admin when writing/editing pages and posts?

There are two ways you can customize this value (in both examples, change 100 to the number you’d like to use):

  1. In your wp-config.php file (in the root directory of your blog), add the following line of code (making sure it is within the opening <?php and closing ?> PHP tags):

    define( 'CUSTOM_FIELD_NAMES_LIMIT', 100 );
    
  2. Somewhere — ideally in a mu-plugin or site-specific plugin, or less ideally your active theme’s functions.php file — hook the ‘c2c_list_more_custom_field_names’ filter and return the number you’d like:

    add_filter( 'c2c_list_more_custom_field_names', function ( $limit ) { return 100; } );
    

Why don’t I see form fields for adding/editing custom fields for a post, as mentioned by documentation for this plugin?

This plugin has no effect for users who make use of the block editor (aka Gutenberg) introduced in WordPress v5.0 because that editor does not directly expose custom fields in the interface. The plugin is still beneficial for users making use of the classic editor.

Does this plugin include unit tests?

Yes.

Vurderinger

11. september, 2019
I hadn't realised that there was a limit on the Custom Fields in the dropdown within the Page. This is a lovely little plugin to get around this problem. Thanks.
Les alle 3 vurderinger

Bidragsytere og utviklere

“List More Custom Field Names” er programvare med åpen kildekode. Følgende personer har bidratt til denne utvidelsen.

Bidragsytere

Endringslogg

1.3.9 (2023-06-06)

  • Change: Note compatibility through WP 6.3+
  • Change: Update copyright date (2023)
  • New: Add .gitignore file
  • Unit tests:
    • Allow tests to run against current versions of WordPress
    • New: Add composer.json for PHPUnit Polyfill dependency
    • Change: Prevent PHP warnings due to missing core-related generated files

1.3.8 (2021-09-17)

  • Change: Note compatibility through WP 5.8+
  • Change: Update usage instructions to use anonymous function instead of create_function() (as was done in filter example in v1.3.3)
  • Change: Tweak indentation for code examples in readme.txt
  • Unit tests:
    • Change: Restructure unit test directories
      • Change: Move phpunit/ into tests/
      • Change: Move phpunit/bin into tests/
    • Change: Remove ‘test-‘ prefix from unit test file
    • Change: In bootstrap, store path to plugin file constant
    • Change: In bootstrap, add backcompat for PHPUnit pre-v6.0
    • New: Add test for a negative value returned from filter

1.3.7 (2021-04-10)

  • Change: Note compatibility through WP 5.7+
  • Change: Update copyright date (2021)

Full changelog is available in CHANGELOG.md.