block editor – WordPress Gutenberg – Sidebar get posts list based on selected category

Question

I need to display the complete posts list in the dropdown list in the custom block sidebar.

I used for that withSelect:

...
    const currentPostId = select('core/editor').getCurrentPostId();

    const query = {
                orderby : 'date',
                order : 'asc',
                status : 'publish',
                per_page: -1,
                exclude: currentPostId,
    }
    return {articleList: select('core').getEntityRecords('postType', 'post', query)}

...

My issue is that I have a lot lot lot lot … of posts and so it takes a life to get the list in my selectControl.

I so tried to reduce the number of retrieved posts by first selecting the list of categories (same king of code). But how can I so retrieve posts based on the selected category?

Thx!

0
Venizia 1 year 2022-02-09T09:50:46-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse