Skip to content

Commit

Permalink
fix: Restrict sticky post handling to 'post' post type
Browse files Browse the repository at this point in the history
  • Loading branch information
dhananjaykuber committed Jan 21, 2025
1 parent 84d7873 commit f311fa4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/block-library/src/post-template/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit f311fa4

Please sign in to comment.