{"id":4894,"date":"2020-06-03T14:17:08","date_gmt":"2020-06-03T14:17:08","guid":{"rendered":"https:\/\/the7kennisbank.nl\/?p=4894"},"modified":"2020-06-09T13:22:22","modified_gmt":"2020-06-09T13:22:22","slug":"filter-grid-query-args","status":"publish","type":"post","link":"https:\/\/the7kennisbank.nl\/en\/wp-grid-builder\/filter-grid-query-args\/","title":{"rendered":"Filter grid query args"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element \" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<div>\n<div class=\"container flex items-center justify-between\">\n<h1 class=\"entry-title\">\/grid\/query_args<\/h1>\n<\/div>\n<\/div>\n<div id=\"article-wrapper\" class=\"container\">\n<p>This filter is called before the grid query is ran to fetch posts, terms or users.<\/p>\n<p>It allows to dynamically change the query args of <code>WP_Query<\/code> , <code>WP_Term_Query<\/code>\u00a0or\u00a0<code>WP_User_Query<\/code><\/p>\n<table>\n<tbody>\n<tr>\n<td>Argument<\/td>\n<td>Type<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>$query_args<\/td>\n<td>array<\/td>\n<td>Holds query arguments<\/td>\n<\/tr>\n<tr>\n<td>$grid_id<\/td>\n<td>integer<\/td>\n<td>Grid id<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"code-syntax-block code-syntax-wrapper\">\n<p>[pastacode lang=&#8221;php&#8221; manual=&#8221;function%20prefix_query_args(%20%24query_args%2C%20%24grid_id%20)%20%7B%0A%0A%09%2F%2F%20If%20it%20matches%20grid%20id%201%2C%20we%20exclude%20post%20IDs%201%2C2%2C3%2C4.%20%0A%09if%20(%201%20%3D%3D%3D%20%24grid_id%20)%20%7B%20%24query_args%5B&#8217;post__not_in&#8217;%5D%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%3B%0A%0A%09%7D%0A%0A%09return%20%24query_args%3B%0A%0A%7D%0A%0Aadd_filter(%20&#8217;wp_grid_builder%2Fgrid%2Fquery_args&#8217;%2C%20&#8217;prefix_query_args&#8217;%2C%2010%2C%202%20)%3B&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>\n<\/div>\n<\/div>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\/grid\/query_args This filter is called before the grid query is ran to fetch posts, terms or users. It allows to dynamically change the query args of WP_Query , WP_Term_Query\u00a0or\u00a0WP_User_Query Argument Type Description $query_args array Holds query arguments $grid_id integer Grid id [pastacode lang=&#8221;php&#8221; manual=&#8221;function%20prefix_query_args(%20%24query_args%2C%20%24grid_id%20)%20%7B%0A%0A%09%2F%2F%20If%20it%20matches%20grid%20id%201%2C%20we%20exclude%20post%20IDs%201%2C2%2C3%2C4.%20%0A%09if%20(%201%20%3D%3D%3D%20%24grid_id%20)%20%7B%20%24query_args%5B&#8217;post__not_in&#8217;%5D%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%3B%0A%0A%09%7D%0A%0A%09return%20%24query_args%3B%0A%0A%7D%0A%0Aadd_filter(%20&#8217;wp_grid_builder%2Fgrid%2Fquery_args&#8217;%2C%20&#8217;prefix_query_args&#8217;%2C%2010%2C%202%20)%3B&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>\n","protected":false},"author":2,"featured_media":4996,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[44,57,43],"tags":[],"class_list":["post-4894","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-documentation","category-php-filters","category-wp-grid-builder","category-44","category-57","category-43","description-off"],"acf":[],"_links":{"self":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/4894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/comments?post=4894"}],"version-history":[{"count":3,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/4894\/revisions"}],"predecessor-version":[{"id":5107,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/4894\/revisions\/5107"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/media\/4996"}],"wp:attachment":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/media?parent=4894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/categories?post=4894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/tags?post=4894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}