1. Password Protected Categories
  2. Developer Documentation

Retrieving password protected categories

The following information is aimed at developers. If you don't know how to use it then we recommend asking your developer or posting a job on Codeable to get a quote from an experienced developer.

Need professional assistance?
We've partnered with Codeable to provide our customers with expert help if required.

If you are retrieving the category-tree with a custom WP REST API endpoint then you can add a parameter to retrieve password protected categories.

You can do this by adding the 'meta_key' and optionally adding the 'meta_value' parameters. For example, to retrieve all password protected categories, you could use:

$password_protected_cats = get_categories( [
'meta_key' => 'password'
] );

You can also achieve the same result by using using 'meta_value' together with 'meta_key'. So to select all password protected categories:

$private_cats = get_categories( [
'meta_key' => 'visibility',
'meta_value' => 'protected'
] );

The following example would select all private categories rather than password protected categories:

$private_cats = get_categories( [
'meta_key' => 'visibility',
'meta_value' => 'private'
] );
Still need help?
If searching the knowledge base hasn't answered your question, please contact support.

Related Articles