{"id":4875,"date":"2020-06-04T10:56:33","date_gmt":"2020-06-04T10:56:33","guid":{"rendered":"https:\/\/the7kennisbank.nl\/?p=4875"},"modified":"2020-06-09T13:08:34","modified_gmt":"2020-06-09T13:08:34","slug":"facet-methods","status":"publish","type":"post","link":"https:\/\/the7kennisbank.nl\/en\/wp-grid-builder\/documentation\/facet-methods\/","title":{"rendered":"Facet methods"},"content":{"rendered":"
\n\t
\n\t\t
\n\t\t\t
\n
\n

Facet methods<\/h1>\n<\/div>\n<\/div>\n
\n

This method allows to initialize facets script. It\u2019s mainly used if you destroy()<\/code> the instance. Otherwise, there isn\u2019t any reason to init()<\/code> facets since it\u2019s automatically done by the plugin on load.<\/p>\n

\n

[pastacode lang=”javascript” manual=”wpgb.facets.init()%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

You can destroy facets instance at any time thanks to this method.<\/p>\n

\n

[pastacode lang=”javascript” manual=”wpgb.facets.destroy()%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to refresh facets and grid content. It can be useful if you programmatically change facets parameters thanks to setParams()<\/code> or deleteParams()<\/code> methods.<\/p>\n

\n

[pastacode lang=”javascript” manual=”wpgb.facets.refresh()%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to abort an asynchronous task like refresh()<\/code> method. It prevents making several requests at the same time which can lead to wrong results.<\/p>\n

\n

[pastacode lang=”javascript” manual=”wpgb.facets.abort()%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to modify browser history and url. It is generally used after modifying facets parameters thanks to setParams()<\/code> or deleteParams()<\/code> methods and before to refresh()<\/code> content.<\/p>\n

\n

[pastacode lang=”javascript” manual=”wpgb.facets.pushState()%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to modify browser history and url. It is generally used after modifying facets parameters thanks to setParams()<\/code> or deleteParams()<\/code> methods and before to refresh()<\/code> content.<\/p>\n\n\n\n\n
Argument<\/td>\nType<\/td>\nDescription<\/td>\n<\/tr>\n
facets<\/td>\nnull|array<\/td>\nHold facet slug(s) to reset<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n

[pastacode lang=”javascript” manual=”%2F%2F%20Reset%20all%20facets.%0Awpgb.facets.reset()%3B%0A%2F%2F%20Reset%20specific%20facets%0A.wpgb.facets.reset(%20%5B’facet_slug_1’%2C%20’facet_slug_2’%5D%20)%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to get facet(s) properties.<\/p>\n\n\n\n\n
Argument<\/td>\nType<\/td>\nDescription<\/td>\n<\/tr>\n
facet<\/td>\ninteger|string<\/td>\nFacet id or slug<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n

[pastacode lang=”javascript” manual=”%2F%2F%20Get%20specific%20facet%20by%20its%20id.%0Awpgb.facets.getFacet(%201%20)%3B%0A%2F%2F%20Get%20specific%20facet%20by%20its%20slug.%0Awpgb.facets.getFacet(%20’facet_slug’%20)%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to check if a facet exists.<\/p>\n\n\n\n\n
Argument<\/td>\nType<\/td>\nDescription<\/td>\n<\/tr>\n
facet<\/td>\ninteger|string<\/td>\nFacet id or slug<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n

[pastacode lang=”javascript” manual=”%2F%2F%20Check%20if%20facet%20exists%20by%20its%20id.%0Awpgb.facets.hasFacet(%201%20)%3B%0A%2F%2F%20Check%20if%20facet%20exists%20by%20its%20slug.%0Awpgb.facets.hasFacet(%20’facet_slug’%20)%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to get parameters (selected values) of a facet.<\/p>\n\n\n\n\n
Argument<\/td>\nType<\/td>\nDescription<\/td>\n<\/tr>\n
facet<\/td>\nstring<\/td>\nFacet slug<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n

[pastacode lang=”javascript” manual=”wpgb.facets.getParams(%20’facet_slug’%20)%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to check if a facet has parameters (selected values).<\/p>\n\n\n\n\n
Argument<\/td>\nType<\/td>\nDescription<\/td>\n<\/tr>\n
facet<\/td>\nstring<\/td>\nFacet slug<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n

[pastacode lang=”javascript” manual=”wpgb.facets.hasParams(%20’facet_slug’%20)%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to assign parameters (selected values) to a facet.<\/p>\n\n\n\n\n\n
Argument<\/td>\nType<\/td>\nDescription<\/td>\n<\/tr>\n
facet<\/td>\nstring<\/td>\nFacet slug<\/td>\n<\/tr>\n
params<\/td>\narray<\/td>\nHolds facet parameters as string<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n

[pastacode lang=”javascript” manual=”wpgb.facets.setParams(%20’facet_slug’%2C%20%5B’param1’%2C%20’param2’%5D%20)%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n

This methods allows to delete parameters (selected values) from a facet.<\/p>\n\n\n\n\n\n
Argument<\/td>\nType<\/td>\nDescription<\/td>\n<\/tr>\n
facet<\/td>\nstring<\/td>\nFacet slug<\/td>\n<\/tr>\n
params<\/td>\narray<\/td>\nHolds facet parameters as string<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n

[pastacode lang=”javascript” manual=”wpgb.facets.deleteParams(%20’facet_slug’%2C%20%5B’param1’%5D%20)%3B” message=”” highlight=”” provider=”manual”\/]<\/p>\n<\/div>\n<\/div>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"

Facet methods This method allows to initialize facets script. It\u2019s mainly used if you destroy() the instance. Otherwise, there isn\u2019t any reason to init() facets since it\u2019s automatically done by the plugin on load. [pastacode lang=”javascript” manual=”wpgb.facets.init()%3B” message=”” highlight=”” provider=”manual”\/] You can destroy facets instance at any time thanks to this method. [pastacode lang=”javascript” manual=”wpgb.facets.destroy()%3B”…<\/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,54],"tags":[],"class_list":["post-4875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-documentation","category-js-methods","category-44","category-54","description-off"],"acf":[],"_links":{"self":[{"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/4875","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=4875"}],"version-history":[{"count":2,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/4875\/revisions"}],"predecessor-version":[{"id":5184,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/posts\/4875\/revisions\/5184"}],"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=4875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/categories?post=4875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/the7kennisbank.nl\/en\/wp-json\/wp\/v2\/tags?post=4875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}