Skip to content

Commit

Permalink
change sticky options labels
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Oct 23, 2020
1 parent 81369fd commit 34f5966
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/query-loop/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function QueryLoopEdit( {
query.exclude = exclude;
}
if ( sticky ) {
query.sticky = sticky === 'show';
query.sticky = sticky === 'only';
}
return {
posts: getEntityRecords( 'postType', postType, query ),
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/query-loop/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function render_block_core_query_loop( $attributes, $content, $block ) {
}
if ( isset( $block->context['query']['sticky'] ) && ! empty( $block->context['query']['sticky'] ) ) {
$sticky = get_option( 'sticky_posts' );
if ( 'show' === $block->context['query']['sticky'] ) {
if ( 'only' === $block->context['query']['sticky'] ) {
$query['post__in'] = $sticky;
} else {
$query['post__not_in'] = array_merge( $query['post__not_in'], $sticky );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ export default function QueryInspectorControls( { query, setQuery } ) {
}, [ querySearch, onChangeDebounced ] );
const stickyOptions = useMemo( () => [
{
label: __( 'All posts' ),
label: __( 'Include' ),
value: '',
},
{ label: __( 'Only sticky posts' ), value: 'show' },
{ label: __( 'Exclude sticky posts' ), value: 'exclude' },
{ label: __( 'Exclude' ), value: 'exclude' },
{ label: __( 'Only' ), value: 'only' },
] );
return (
<InspectorControls>
Expand Down Expand Up @@ -184,9 +184,9 @@ export default function QueryInspectorControls( { query, setQuery } ) {
/>
{ showSticky && (
<SelectControl
label={ __( 'Sticky posts' ) }
options={ stickyOptions }
value={ sticky }
label={ __( 'Sticky' ) }
onChange={ ( value ) => setQuery( { sticky: value } ) }
/>
) }
Expand Down

0 comments on commit 34f5966

Please sign in to comment.