Skip Navigation

[Resolved] How to render a View in a PHP template

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

Problem:
Client has a View they want to render directly in a PHP template.

Solution:
Use the API function render_view, passing an array of arguments which should, at least, specify the title or name (slug) of the View, e.g.

echo render_view( array( 'name' => 'view-slug' ) );

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-api/#render_view

100% of people find this useful.

This support ticket is created 6 years, 6 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by jefM 6 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#733106

I created a view that is a slider of quotes.
I want to display the slider on every page just above te footer. How do I translate the shortcode of the view [wpv-view name="getuigenissen-slider-pagination"] in php so i can implement this in footer.php of the theme?

I used https://toolset.com/documentation/programmer-reference/views-api/#render_view but it is but there is less documentation for a non-programmer.

example of the slider working on a testpage: hidden link

#733111

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

If your View name is getuigenissen-slider-pagination then you would use the render_view function in your PHP template like so:

echo render_view( array( 'name' => 'getuigenissen-slider-pagination' ) );

Do you want to try that and check that it works?

#735115

Thanks Nigel, this solution works