Skip Navigation

[Resolved] Passing arguments

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

Problem:
how to Passing arguments to view and filter by view's shortcode attribute

Solution:
You can filter your view with shortcode attribute by adding custom attribute to your view.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/passing-arguments/#post-920725

Relevant Documentation:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes

This support ticket is created 6 years, 4 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
- 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 5 replies, has 2 voices.

Last updated by briana-5 6 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#919648

I have two custom post types. The first is called "Bills" the second is called "Com Hearings". In Bills and Com Hearings, each post has a unique identifier in a custom field called "Bill_ID" (in the bills post type it's actually named bill_id_bills). I have a content template that is the default display for the Bills post type. What I'm trying to do is match the value in the "Bill_ID_bills" field in "Bills" with the value in the "Bill_ID" field in "Com Hearings" and when those two values match, display the "Hearing Date" field from the Com Hearings post type.

I tried to follow the instructions for passing arguments to views, but it doesn't work. https://toolset.com/documentation/user-guides/passing-arguments-to-views/

Here are the steps I've taken:

I created a view for the "Com Hearings" post type. I included a query filter that says "the field Bill_ID is a 'string' that is 'equal to' the following: 'shortcode attribute' "billid". In the loop I included the field "hearing date" from Com Hearings".

Next, I edited the content template for Bills. In the template window I included the following code:

[wpv-view name="com-hearings-view" billid="[types field="bill_id_bills" output="raw"][/types]"]

When I display the content template for bills, what it gives me is multiple hearing dates...it displays the hearing date for every post in Com Hearings, rather than the hearing date for the one post in which the value in Bill_id matches the value for Bill_id_bills. It doesn't seem to recognize the argument "billid=" . What is the solution?

#919842

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - could you please share problem URL and access details so I can check whats going wrong with your view and setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#920157

Minesh
Supporter

Languages: English (English )

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

Could you please check now. I think you added a wrong custom filed filter as I can see multiple custom fields with same bill_id.

I've corrected that as:

Select items with field:
BILL_ID is a string equal to VIEW_PARAM(billid)

I can see its displaying the correct results.
=> hidden link

Could you please confirm.

#920505

Can you clarify where exactly you made that change and what field I had and what field you changed it to?

#920725

Minesh
Supporter

Languages: English (English )

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

Well - I've added the view's code as given under to content template:
=> hidden link

DISPLAY THIS THING:[wpv-view name="com-hearings-view" billid="[types field='bill_id_bills' output='raw'][/types]"]

And then with your view I removed the filter and added the filter for custom field BILL_ID.

#921397

Thanks! I see now what I did. Works great.