最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

block editor - Wordpress Gutenberg - Sidebar get posts list based on selected category

programmeradmin0浏览0评论

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)

  1. 暂无评论