Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'enhancement/posts-list-offset' into release/3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
admturner committed Apr 2, 2024
2 parents c4d4878 + 397f2b2 commit 13578a0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/blocks/posts-list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
"addLinkToFeaturedImage": {
"type": "boolean",
"default": false
},
"offsetPostsNumber": {
"type": "integer",
"default": 0
}
},
"supports": {
Expand Down
15 changes: 14 additions & 1 deletion src/blocks/posts-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function PostsListEdit( { attributes, setAttributes } ) {
displayPostTaxonomy,
postLayout,
columns,
offsetPostsNumber,
order,
orderBy,
selectedTermLists,
Expand Down Expand Up @@ -105,6 +106,7 @@ export default function PostsListEdit( { attributes, setAttributes } ) {
order,
orderby: orderBy,
per_page: postsToShow,
offset: offsetPostsNumber,
_embed: 'wp:featuredmedia',
},
( value ) => ! isUndefined( value )
Expand Down Expand Up @@ -161,6 +163,7 @@ export default function PostsListEdit( { attributes, setAttributes } ) {
postsToShow,
order,
orderBy,
offsetPostsNumber,
selectedTermLists,
]
);
Expand Down Expand Up @@ -402,14 +405,24 @@ export default function PostsListEdit( { attributes, setAttributes } ) {
}
/>

<RangeControl
label={ __( 'The number of items to offset.' ) }
value={ offsetPostsNumber }
onChange={ ( value ) =>
setAttributes( { offsetPostsNumber: value } )
}
min={ 0 }
max={ 100 }
/>

{ postLayout === 'grid' && (
<RangeControl
label={ __( 'Columns' ) }
value={ columns }
onChange={ ( value ) =>
setAttributes( { columns: value } )
}
min={ 2 }
min={ 1 }
max={
! hasPosts
? MAX_POSTS_COLUMNS
Expand Down
1 change: 1 addition & 0 deletions src/blocks/posts-list/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function render( $attributes ) {
'post_status' => 'publish',
'order' => $attributes['order'],
'orderby' => $attributes['orderBy'],
'offset' => $attributes['offsetPostsNumber'],
'suppress_filters' => false,
);

Expand Down
2 changes: 0 additions & 2 deletions src/blocks/posts-list/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@

@media (min-width: 576px) {

.hrswp-block-posts-list.is-grid,
.hrswp-block-posts-list.is-grid.columns-1,
.hrswp-block-posts-list.is-grid.columns-2,
.hrswp-block-posts-list.is-grid.columns-3,
.hrswp-block-posts-list.is-grid.columns-4,
Expand Down

0 comments on commit 13578a0

Please sign in to comment.