Skip to content

Commit

Permalink
fix: specific posts behavior in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoo committed Mar 30, 2022
1 parent 1226c7d commit b9fd0e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions includes/class-newspack-blocks-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ public static function posts_endpoint( $request ) {
$args['post__not_in'] = $attributes['exclude'];
}

if ( $attributes['include'] && count( $attributes['include'] ) ) {
$args['post__in'] = $attributes['include'];
}

$query = new WP_Query( $args );
$posts = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ public function register_routes() {
),
'default' => array(),
],
'include' => [
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
],
]
),
'permission_callback' => function() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/query-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class QueryControls extends Component {
return apiFetch( {
url: addQueryArgs( restUrl, {
search,
per_page: 20,
postsToShow: 20,
_fields: 'id,title',
type: 'post',
post_type: postType,
postType,
} ),
} ).then( function ( posts ) {
const result = posts.map( post => ( {
Expand Down

0 comments on commit b9fd0e4

Please sign in to comment.