PageSourceSearch

https://fulltextsearch.org/docs/_next/static/chunks/pages/en/archi…/posts_distinct-ba9f1aae375e1b55.js

js fulltextsearch.org collected 2026-09-25 21:07:49 UTC 3,813 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6695],{20422:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/en/architecture/hooks_usage/posts_distinct",function(){return n(2797)}])},2797:function(e,s,n){"use strict";n.r(s),n.d(s,{useTOC:function(){return useTOC}});var i=n(85893),t=n(37812),o=n(80390),d=n(38925);function useTOC(e){let s={code:"code",...(0,d.a)()};return[{value:(0,i.jsxs)(i.Fragment,{children:["The ",(0,i.jsx)(s.code,{children:"posts_distinct"})," Hook in WPFTS"]}),id:"the-posts_distinct-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,d.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_distinct"})," hook in WordPress is a filter that allows modification of the ",(0,i.jsx)(n.code,{children:"DISTINCT"})," keyword in the SQL query used to retrieve posts. WPFTS utilizes this hook to add or remove the ",(0,i.jsx)(n.code,{children:"SQL_NO_CACHE"})," directive depending on the plugin’s settings."]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsxs)(n.strong,{children:["What WPFTS Does When ",(0,i.jsx)(n.code,{children:"posts_distinct"})," is Called:"]})}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsxs)(n.strong,{children:["Adding or Removing ",(0,i.jsx)(n.code,{children:"SQL_NO_CACHE"}),":"]})," WPFTS checks the value of the ",(0,i.jsx)(n.code,{children:"wpfts_nocache"})," option (via ",(0,i.jsx)(n.code,{children:"$wpq->wpftsi_session['wpfts_nocache']"}),"). If this option is enabled (value greater than 0), the plugin adds the ",(0,i.jsx)(n.code,{children:"SQL_NO_CACHE"})," directive to the ",(0,i.jsx)(n.code,{children:"DISTINCT"})," keyword. If the option is disabled, the ",(0,i.jsx)(n.code,{children:"SQL_NO_CACHE"})," directive is removed from the query if it was present. The ",(0,i.jsx)(n.code,{children:"SQL_NO_CACHE"})," directive instructs MySQL not to cache the query results, which can be beneficial during debugging or with frequently changing data. However, this can decrease performance. Therefore, by default, this option is disabled, and WPFTS removes the directive from the query."]}),"\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_distinct"})," Handling:"]})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"WPFTS_Search::index_posts_distinct()"})}),"\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 should be aware that WPFTS might add or remove the ",(0,i.jsx)(n.code,{children:"SQL_NO_CACHE"})," directive in the query. If your addon also works with this directive, ensure your logic does not 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 manages the ",(0,i.jsx)(n.code,{children:"SQL_NO_CACHE"})," directive based on the ",(0,i.jsx)(n.code,{children:"wpfts_nocache"})," option."]}),"\n",(0,i.jsxs)(n.li,{children:["This hook is called for all ",(0,i.jsx)(n.code,{children:"WP_Query"})," queries, but WPFTS only processes it for search-related queries."]}),"\n"]})]})},"/en/architecture/hooks_usage/posts_distinct",{filePath:"pages/en/architecture/hooks_usage/posts_distinct.md",timestamp:1733329702e3,pageMap:o.v,frontMatter:{},title:"Posts Distinct"},"undefined"==typeof RemoteContent?useTOC:RemoteContent.useTOC)}},function(e){e.O(0,[9993,9774,2888,179],function(){return e(e.s=20422)}),_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.