Skip to content

Commit

Permalink
Merge branch 'feature/post-list/sticky-posts' of https://github.com/v…
Browse files Browse the repository at this point in the history
…ektor-inc/vk-blocks-pro into feature/post-list/sticky-posts
  • Loading branch information
mthaichi committed Feb 6, 2025
2 parents 84b9485 + 41fe3e2 commit 86ca0da
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions inc/vk-blocks/view/class-vk-blocks-postlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,26 +218,23 @@ public static function get_loop_query( $attributes ) {
$args['date_query'] = $date_query;
}

$sticky_posts = isset( $attributes['stickyPosts'] ) ? $attributes['stickyPosts'] : 'include';
$sticky_posts_mode = isset( $attributes['stickyPosts'] ) ? $attributes['stickyPosts'] : 'include';

switch ( $sticky_posts ) {
switch ( $sticky_posts_mode ) {
case 'include':
$args['ignore_sticky_posts'] = false;
break;

case 'exclude':
$args['post__not_in'] = array_merge( $args['post__not_in'], get_option( 'sticky_posts' ) );
$args['ignore_sticky_posts'] = true;
$args['post__not_in'] = array_merge( isset( $args['post__not_in'] ) ? $args['post__not_in'] : array(), get_option( 'sticky_posts' ) );
break;

case 'only':
$sticky_posts = get_option( 'sticky_posts' );
$sticky_posts = get_option( 'sticky_posts' );
$args['post__in'] = ! empty( $sticky_posts ) ? $sticky_posts : array( 0 );
if ( ! empty( $sticky_posts ) ) {
$args['post__in'] = $sticky_posts;
$args['posts_per_page'] = count( $sticky_posts );
$args['orderby'] = 'post__in';
} else {
$args['post__in'] = array( 0 );
}
break;
}
Expand Down

0 comments on commit 86ca0da

Please sign in to comment.