post_grid_filter_query_args

You can add more query arguments by filter hook that’s supported by WP_Query

function post_grid_filter_query_args_extra($query_args){
    
  $current_post_id = get_the_ID();
  
  $extra_query = array (

      'post__not_in' => array($current_post_id),

      );

  return array_merge($query_args, $extra_query);
  }

add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra');

This filter hook will affect all of your post grid created on your site.

 

Filter different grid query arguments, (Only available in premium version)

function post_grid_filter_query_args_extra($query_args, $grid_id){
    
  if($grid_id==7){

    $extra_query = array (
      'post__in' => array('1241'),
    );

    $query_args = array_merge($query_args, $extra_query);
    }

  return $query_args;

}

add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra',10,2);

 

Query post on the author page

function post_grid_filter_query_args_extra($query_args){

    if(is_author()){

        $author = get_queried_object();
        $author_id = isset($author->ID) ? $author->ID : '';

        if(!empty($author_id))
        $query_args['author'] = $author->ID;

    }


    return $query_args;
}

add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra');

 

Display on the single post page

function post_grid_filter_query_args_is_singular($query_args){

    if(is_singular()):
        $current_post_id = get_the_ID();
        $query_args['post__not_in'] = array($current_post_id);
    endif;

    return $query_args;
}

add_filter('post_grid_filter_query_args','post_grid_filter_query_args_is_singular');

 

Load diffrent post per page on mobile devices.

function post_grid_filter_query_args_is_mobile($query_args){

    if(wp_is_mobile()):
        $query_args['posts_per_page'] = 2;
    endif;

    return $query_args;
}

add_filter('post_grid_filter_query_args','post_grid_filter_query_args_is_mobile');