Skip Navigation

[Resolved] Need to replace Google Site Search

This thread is resolved. Here is a description of the problem and solution.

Problem:
Is there a way to add a view to every page of the site? What is the PHP syntax for loading a WP-Types view directly into the WordPress header.php file?

Solution:
You can try with Views function render_view(), for example:

$args = array(
    'title' => 'My View name',
);
echo render_view( $args );

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-api/#render_view
Renders a View and returns the HTML output.

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#586924

hidden link currently has a search box in the header. I need to be able to add a view to every page on the site that will contain the Javascript for handling that field. I intend to replace the current Google script and replace the iFrame of contents that Google is currently returning with search results from the Relevanssi plugin I currently have installed on the site.

Is there a way to add a view to every page of the site? If so, I would add JS to that view which would handle the submit event from the search form, request Relevanssi results using the new REST API that Relevanssi is providing to me, and then I would write javascript to iterate through the results and populate the hidden, floating div that the Google results appear in with the results from the Relevanssi query.

The only think I don't know how to do is make a view that I can put in the site header, footer, or some other means of making that particular View appears in every page of the site where the search box is visible.

I guess my question is really: What is the PHP syntax for loading a WP-Types view directly into the WordPress header.php file?

It would also work in the Footer, I think, but I'm lost as to how to make the same view persist throughout the site.

#587001

Dear Patrick,

You can try with Views function render_view(), for example:

$args = array(
    'title' => 'My View name',
);
echo render_view( $args );

See our document:
https://toolset.com/documentation/programmer-reference/views-api/#render_view
Renders a View and returns the HTML output.

#587196

That's the missing, magical piece! Thank you!

#587365

You are welcome

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.