1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6813],{10026:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/en/architecture/hooks_usage/posts_join",function(){return n(37282)}])},37282:function(e,s,n){"use strict";n.r(s),n.d(s,{useTOC:function(){return useTOC}});var i=n(85893),o=n(37812),t=n(80390),r=n(38925);function useTOC(e){let s={code:"code",...(0,r.a)()};return[{value:(0,i.jsxs)(i.Fragment,{children:["The ",(0,i.jsx)(s.code,{children:"posts_join"})," Hook in WPFTS"]}),id:"the-posts_join-hook-in-wpfts",depth:2}]}s.default=(0,o.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,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h2,{id:s[0].id,children:s[0].value}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"posts_join"})," hook in WordPress is a filter that allows modification of the SQL ",(0,i.jsx)(n.code,{children:"JOIN"})," clause used to combine tables in a query. WPFTS uses this hook to join the posts table (",(0,i.jsx)(n.code,{children:"wp_posts"}),") with a temporary table containing post relevance information calculated by the pluginâs search engine."]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsxs)(n.strong,{children:["What WPFTS Does When ",(0,i.jsx)(n.code,{children:"posts_join"})," is Called:"]})}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Checks for Indexed Search Usage:"})," The plugin checks if indexed search is enabled in WPFTS (",(0,i.jsx)(n.code,{children:"$wpq->wpftsi_session['use_indexed_search']"}),")."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Adds JOIN with Temporary Table:"})," If indexed search is enabled, WPFTS adds a ",(0,i.jsx)(n.code,{children:"JOIN"})," with a temporary table (aliased as ",(0,i.jsx)(n.code,{children:"wpfts_t"}),"), which contains post IDs and their relevance scores. This allows retrieving the relevance score for each post in the search results."]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsxs)(n.strong,{children:["Important Functions Involved in ",(0,i.jsx)(n.code,{children:"posts_join"})," Handling:"]})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"WPFTS_Search::index_sql_joins()"})}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"How to Use This in Addon Development:"})}),"\n",(0,i.jsxs)(n.p,{children:["Addon developers need to be aware that WPFTS might add its own ",(0,i.jsx)(n.code,{children:"JOIN"}),"s to the SQL query. If your addon also uses ",(0,i.jsx)(n.code,{children:"JOIN"}),"s, ensure your logic doesnât conflict with WPFTS."]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Additional Notes:"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["WPFTS only adds the ",(0,i.jsx)(n.code,{children:"JOIN"})," when indexed search is used."]}),"\n",(0,i.jsxs)(n.li,{children:["The temporary relevance table is created in the ",(0,i.jsx)(n.code,{children:"WPFTS_Search::sql_parts()"})," method."]}),"\n",(0,i.jsx)(n.li,{children:"This hook demonstrates how WPFTS integrates its search engine with WordPress at the SQL query level."}),"\n"]})]})},"/en/architecture/hooks_usage/posts_join",{filePath:"pages/en/architecture/hooks_usage/posts_join.md",timestamp:1733329702e3,pageMap:t.v,frontMatter:{},title:"Posts Join"},"undefined"==typeof RemoteContent?useTOC:RemoteContent.useTOC)}},function(e){e.O(0,[9993,9774,2888,179],function(){return e(e.s=10026)}),_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.