WordPress filter hook

pll_get_post_types

Fired by 4 WordPress plugins, running on 917K+ sites between them.

“This filter is documented in src/model.php”

How to use pll_get_post_types

It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'pll_get_post_types', function( $public_post_types, $arg2 ) {
	// Change $public_post_types here.
	return $public_post_types;
}, 10, 2 );

Argument names come from Polylang's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

4 plugins that fire pll_get_post_types

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Polylang icon Polylang900,000+ installs apply_filters( 'pll_get_post_types', $public_post_types, true ) src/settings/settings-cpt.php:66
  2. Toolkit for Polylang icon Toolkit for Polylang10,000+ installs apply_filters( 'pll_get_post_types', $public_post_types, true ) includes/inspector/checks/class-dupcap-check-content.php:238
  3. Ray Enterprise Translation icon Ray Enterprise Translation7,000+ installs apply_filters( 'pll_get_post_types', $polylang_enabled, false ) admin/post-actions.php:46
  4. Show Language Counts for Polylang icon Show Language Counts for PolylangFewer than 10 installs apply_filters( 'pll_get_post_types', $defaults, false ) show-language-counts-for-polylang.php:183

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.