Expand WordPress search

If you want to add meta fields to the native WordPress search, for example, it is advisable to take a look at the fired filters . The posts_search hook is recommended so that pagination continues to work and future improvements in the search are not canceled out . With the help of the REGEXP and ExtractValue functions, the following code extends this search to include posts that contain one of the search words entered in all meta fields.