Skip Navigation

[Resolved] How to use the View shortcode attribute

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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 3 replies, has 3 voices.

Last updated by Mateus Getulio 1 year, 2 months ago.

Assisted by: Mateus Getulio.

Author
Posts
#2661953

jum

Tell us what you are trying to do?
I have a View and want to show the post based on the query filter custom email field is equal to the current login user email.

In settings->Frontend content-> third party shortcode I added wpv-current-user
In view->content selection->query filter added Custom email field equal to shortcode attribute useremail.
Custom email field is a string equal to VIEW_PARAM(useremail)

But I am not sure how to pass this. Where do I need to place this?
[wpv-view name="viewname" useremail="[wpv-current-user info="email" ]"]

I searched several topics but it's not clear how to use this.

Is there any documentation that you are following?
https://toolset.com/forums/topic/filter-view-by-custom-field/
https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/

Please guide me on how to use this shortcode attribute.

#2661979

Nigel
Supporter

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

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

Hi there

It's not clear if you are using the block editor or the legacy editor.

Passing arguments to a View via shortcode attributes is essentially a feature of the legacy editor, inasmuch as you can only add a shortcode attribute when inserting a View using the wpv-view shortcode. If you insert a View using blocks there is no way to provide such a shortcode attribute.

Regardless of whether you created a View with the legacy editor or with the block editor, to pass a shortcode attribute you must insert the View where it is needed via the wpv-view shortcode.

If you are using the block editor this may not make sense, in that you already created the View in-situ on a page, which may be where you want the View to appear.

A better option in that scenario might be to use the Views API instead. Remove the query filter that you added to the View and use the wpv_filter_query API hook to add a meta_query condition for the custom email field to see if it matches the email address of the current user.

See https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

If you need help with that, let us know.

#2661991

jum

Hi Nigel,

Thanks for supporting.
I use Block Editor. I followed these steps and it seems it works for now.

I created two pages.
First page -> Created view(view name= test) with post type and query filter custom field equal to VIEW_PARAM(useremail) and added details post title etc..in view loop.
Second page-> I insert shortcode [wpv-view name="test" useremail="[wpv-current-user info="email" ]"] using the shortcode widget and when I publish and see this page. I can see the list of posts by the current user email.

#2662283

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Thank you for confirming it worked.

I hope we are good to close here.

Feel free to contact us any time if you need assistance with our products.

Kind regards