1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7536],{62013:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/en/architecture/hooks_usage/posts_clauses",function(){return n(52745)}])},52745:function(e,s,n){"use strict";n.r(s),n.d(s,{useTOC:function(){return useTOC}});var o=n(85893),t=n(37812),i=n(80390),r=n(38925);function useTOC(e){let s={code:"code",...(0,r.a)()};return[{value:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(s.code,{children:"posts_clauses"})," Hook in WPFTS"]}),id:"posts_clauses-hook-in-wpfts",depth:2}]}s.default=(0,t.c)(function(e){let{toc:s=useTOC(e)}=e,n={code:"code",h2:"h2",li:"li",ol:"ol",p:"p",strong:"strong",ul:"ul",...(0,r.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h2,{id:s[0].id,children:s[0].value}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"posts_clauses"})," hook in WordPress is a filter that allows modification of various parts of the SQL query used to retrieve posts, including ",(0,o.jsx)(n.code,{children:"FIELDS"}),", ",(0,o.jsx)(n.code,{children:"JOIN"}),", ",(0,o.jsx)(n.code,{children:"WHERE"}),", ",(0,o.jsx)(n.code,{children:"GROUP BY"}),", ",(0,o.jsx)(n.code,{children:"ORDER BY"}),", ",(0,o.jsx)(n.code,{children:"DISTINCT"}),", and ",(0,o.jsx)(n.code,{children:"LIMIT"}),". WPFTS uses this hook ",(0,o.jsx)(n.strong,{children:"solely for collecting information"})," about the query and does not make any changes to it."]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsxs)(n.strong,{children:["What WPFTS does when ",(0,o.jsx)(n.code,{children:"posts_clauses"})," is called:"]})}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Saving query data:"})," WPFTS saves the passed ",(0,o.jsx)(n.code,{children:"$clauses"})," array, containing all parts of the SQL query, into the global array ",(0,o.jsx)(n.code,{children:"$GLOBALS['posts_clauses']"}),". This is done to access the complete SQL query at later stages, for example, for debugging purposes."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returning query data without changes:"})," The plugin returns the ",(0,o.jsx)(n.code,{children:"$clauses"})," array without any modifications. This means that WPFTS does not affect the query itself at this hook."]}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsxs)(n.strong,{children:["Important functions involved in processing ",(0,o.jsx)(n.code,{children:"posts_clauses"}),":"]})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.code,{children:"WPFTS_Search::index_posts_clauses()"})}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"How to use it in addon development:"})}),"\n",(0,o.jsxs)(n.p,{children:["Addon developers should be aware that WPFTS does not modify the query at this hook, but only saves it for later use. If your addon also uses this hook, you can be sure that WPFTS will not interfere with its operation. However, it is worth considering that WPFTS may modify the query on other hooks, such as ",(0,o.jsx)(n.code,{children:"posts_search"}),", ",(0,o.jsx)(n.code,{children:"posts_join"}),", ",(0,o.jsx)(n.code,{children:"posts_orderby"}),", etc."]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"Additional notes:"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:["WPFTS uses the global array ",(0,o.jsx)(n.code,{children:"$GLOBALS['posts_clauses']"})," to store query data."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsx)(n.p,{children:"This hook can be useful for debugging and analyzing SQL queries generated by WordPress."}),"\n"]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"posts_clauses"})," hook in WPFTS is designed only for information gathering and does not affect the query itself. This is important to consider when developing addons."]})]})},"/en/architecture/hooks_usage/posts_clauses",{filePath:"pages/en/architecture/hooks_usage/posts_clauses.md",timestamp:1733329702e3,pageMap:i.v,frontMatter:{},title:"Posts Clauses"},"undefined"==typeof RemoteContent?useTOC:RemoteContent.useTOC)}},function(e){e.O(0,[9993,9774,2888,179],function(){return e(e.s=62013)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.