I would like to have a multi select field for my categories. How can i do that?

My code doesn't work:

    function getCategories () {
        var options = [];
        var categories = wp.data.select('core').getEntityRecords('taxonomy', 'category');
        categories.forEach((category) => {
            options.push({ value: category.id, label: category.name });

        label={__('Select a Post')}
        help={__('Select a post to display as a banner.')}
  • What's the problem you're trying to solve by implementing this? When you say it doesn't work, what does it do instead? Your code looks incomplete, can you update your question to include the full code in its entirety for implementing this? Where are you hoping to put the control? Is it going in a panel? A custom sidebar? A block? It's not obvious where you've put the SelectControl, and the component references choosing posts not categories. Use the edit link under the tags to answer as many of those questions as possible. How are you intending to save the values?
    – Tom J Nowell
    Jul 28, 2020 at 13:30

1 Answer 1


Ich have to write


that solved this problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.