Skip to content

Commit

Permalink
Remove null post warning (#2606)
Browse files Browse the repository at this point in the history
* Tested Up to 6.5

* Test is the post is null before getting the id

* linting
  • Loading branch information
olafleur-godaddy authored Apr 25, 2024
1 parent bbce1c6 commit 898cd3e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/blocks/post-carousel/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function coblocks_render_coblocks_post_carousel_block( $attributes ) {
'order' => $attributes['order'],
'orderby' => $attributes['orderBy'],
'suppress_filters' => false,
'post__not_in' => array( $post->ID ),
'post__not_in' => ! is_null( $post ) ? array( $post->ID ) : array(),
);

if ( isset( $attributes['categories'] ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/posts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function coblocks_render_coblocks_posts_block( $attributes ) {
'order' => $attributes['order'],
'orderby' => $attributes['orderBy'],
'suppress_filters' => false,
'post__not_in' => array( $post->ID ),
'post__not_in' => ! is_null( $post ) ? array( $post->ID ) : array(),
);

if ( isset( $attributes['categories'] ) ) {
Expand Down

0 comments on commit 898cd3e

Please sign in to comment.