Skip Navigation

[Resolved] Display a view in php with filter parameters

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

Problem:
How to display view with additional attribute such as 'limit' using PHP API.

Solution:
To display view using PHP API using additional attributes you can find solution mentioned in the following link.
https://toolset.com/forums/topic/display-a-view-in-php-with-filter-parameters/#post-391047

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-api/

This support ticket is created 8 years 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Guillaume 8 years ago.

Assisted by: Minesh.

Author
Posts
#391039

Hello,

I want to add a view in archives.php

I know the code to display a view in a php page, I use :

<?php echo(render_view(array("id"=>"12345"))); ?>

But here is the shortcode of the view I want to use :

[wpv-view name="view12345" limit="3"]
with a limit or with a Shortcode attribute

Is it possible to add the limit in the php code ?
Or is there a way to add my view shortcode in my archives.php page ?

Thanks

#391047

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Could you please try following:

$args = array(
    'id' => '1111',
    'limit' => '3'
);
echo render_view( $args );

If that does not work.

You can also use views shortcode. For example:

echo do_shortcode('[wpv-view name="view12345" limit="3"]');

I hope one of the option from above will help you to resolve your issue.

#391068

Oh, yes thank you,your both solutions works very well!

Now I have another question. 🙂

If, instead of a static element, for the limit number I want to use a viariable. How can I use it ?

For exemple is another example my filter is "Brand" and I want to use the term of my taxonomy archives for exemple "Adidas". I have this code to display the term in my archive.php page : <?php $taxonomy = get_queried_object(); echo $taxonomy->name; ?>

How can I insert this code into the $args of your code ?

Thanks

#391071

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to hear that both solutions works for you.

As your original issue is resolved. May I kindly ask you to open a new ticket for each new question. This will help other users searching on forum.

Thank you for understanding.

#391082

Ok thanks

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