From f311fa4a64e23927456ead26364ec7506f8e63d3 Mon Sep 17 00:00:00 2001 From: Dhananjay Kuber Date: Tue, 21 Jan 2025 10:59:14 +0530 Subject: [PATCH] fix: Restrict sticky post handling to 'post' post type --- packages/block-library/src/post-template/edit.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/block-library/src/post-template/edit.js b/packages/block-library/src/post-template/edit.js index a978fd7eaf829..3340743a90bde 100644 --- a/packages/block-library/src/post-template/edit.js +++ b/packages/block-library/src/post-template/edit.js @@ -202,6 +202,20 @@ export default function PostTemplateEdit( { // block's postType, which is passed through block context. const usedPostType = previewPostType || postType; + // Only handle sticky posts for 'post' post type. + const shouldHandleSticky = usedPostType === 'post'; + + // If sticky is not applicable for this post type, or sticky is not set + if ( ! shouldHandleSticky ) { + return { + posts: getEntityRecords( 'postType', usedPostType, { + ...query, + ...restQueryArgs, + } ), + blocks: getBlocks( clientId ), + }; + } + // If sticky is not set, it will return all posts in the results. // If sticky is set to `only`, it will limit the results to sticky posts only. // If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`.