0

I want to replace my theme's search functionality with new functionality that searches trough text widgets. Almost all content of my site is provided trough text widgets (they are static pages).

Is there any default wordpress search template that I can use and that will work with my existing search forms?

In regards to Toscho's questions asked here:

  1. My site doesn't have that much content, so slowness is not a problem.
  2. Search results may point to a specific page, the page that hosts the widget
  3. I want only to display results from text widgets.
  • I am not sure how item #2 is supposed to work. You have page specific widgets? – s_ha_dum Oct 20 '13 at 21:34
  • Yes. Each page has a set of textwidgets that display the content. Like this: piclair.com/data/6w5ru.jpg – Forza Oct 20 '13 at 22:12
  • You are doing this the long and hard way. This is really not the way widgets are intended to be used. You are going to be fighting the whole WordPress superstructure starting with how you associate widgets with a page in the first place (which is information necessary to even start thinking about an answer). – s_ha_dum Oct 20 '13 at 22:33
  • Well, the problem is that I have a different design for each and every page of my site. These widgets can also contain html and shortcodes and are thus part of the design. I don't know any other way to do that. – Forza Oct 20 '13 at 22:40
  • Well, custom meta boxes and CPTs come to mind, but you haven't described your actual project much. – s_ha_dum Oct 20 '13 at 22:48
0

Widget content is stored in the $wpdb->options table as serialized data. You can search that with SQL because to SQL serialized data is just a string.

SELECT option_value FROM {$wpdb->options} WHERE meta_value LIKE "something"

But...

  • The table is not indexed for that kind of search
  • Searching serialized data is dicey anyway
  • And I have no idea how you are going to associate the widgets with the pages. That does no happen by default and you have not answered my question about that point.

Put together you aren't going to have a very efficient query and once you jump through hoops to associate the widgets and pages/posts it is going to be even less efficient still.

Sorry, but the decision to build the site the way you have was badly flawed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.