Skip to content

Commit

Permalink
Support an accurate preview of the Related Posts block inside query l…
Browse files Browse the repository at this point in the history
…oop blocks.
  • Loading branch information
JakePT committed Jun 2, 2022
1 parent c0aa3e7 commit 2f3830a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/js/blocks/related-posts/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Edit extends Component {
};

// Use 0 if in the Widgets Screen
const postId = wp.data.select('core/editor').getCurrentPostId() ?? 0;
const { context: { postId = 0 } = {} } = this.props;

wp.apiFetch({
path: addQueryArgs(`/wp/v2/posts/${postId}/related`, urlArgs),
Expand Down
1 change: 1 addition & 0 deletions assets/js/blocks/related-posts/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ registerBlockType('elasticpress/related-posts', {
default: 5,
},
},
usesContext: ['postId'],

/**
* Handle edit
Expand Down

0 comments on commit 2f3830a

Please sign in to comment.