Filters and Hooks | WP Masonry Layout

Filters and Hooks

Filters and Hooks

We currently have only 1 filter.

wmlp_query
Use this filter to write custom query for your shortcode. You can also write custom query based on shortcode Id. You need to write these code in functions.php of your wordpress theme.

For example.

add_filter('wmlp_query', 'my_custom_query_wmlp',10,2);
function my_custom_query_wmlp($args, $shortcodeID){
  $args['posts_per_page'] = 2;
  return $args;
}

If you want to write custom query for specific shortcode, you can use like this.

add_filter('wmlp_query', 'my_custom_query_wmlp',10,2);
function my_custom_query_wmlp($args, $shortcodeID){
  if ($shortcodeID == 2){
    $args['posts_per_page'] = 2;
    return $args;
  }
}