Skip Navigation

[Resolved] Filtering a view within another view by shortcode

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)

This topic contains 0 replies, has 1 voice.

Last updated by davidL-7 3 days, 12 hours ago.

Assisted by: Minesh.

Author
Posts
#2797222

Tell us what you are trying to do?

Hi. I have a custom post type called Aid Requests. Each Aid Request is assigned to an Aid Account.

To manage Aid Accounts, I have another custom post type called Aid Accounts.

Each Aid Account has three custom fields: 1) An Account ID, 2) an Account Name, and 3) An Account Number.

Throughout my app, I'm wanting to use the Account ID as the unique identifier.

On my page that displays the data for a single Aid Request, I want to display the Account Name and Account Number for the Aid Account that it's been assigned to, but the Aid Request only has the Account ID field.

In the View that gets the Aid Request, I'm thinking I can include another View that gets the Aid Account, but I need to figure out how to filter the Aid Account View so that it only gets the one single Aid Account post matching the Account ID.

In my Aid Account View, I filtered by Shortcode attribute, with the value being aidaccountid.

Then in my Aid Request View, I added the Aid Account View like so:

[wpv-view name="display-current-aid-account" aidaccountid="[types field='account-id'][/types]"]

This didn't work (evidently I can't put a types shortcode into the value for the aidaccount id attribute.

When I hardcoded a value, like this:

[wpv-view name="display-current-aid-account" aidaccountid="000000000"]

... it worked.

I'm wondering if it's possible to achieve what I want this way?

What is the link to your site?

See: hidden link

In the list at the top where it says "Account Number", we see what I would like to display: The Account Number, followed by the Account Name in parentheses.

The next list item, "Account (New and Improved)" is where I've inserted my View for display-current-aid-account, but as you'll see, it's not filtering to the single account that this Aid Request is assigned to.

Any guidance on how I can achieve what I'm aiming to do?

#2797240

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I am not sure if you want to use the current structure or you know about the post-relationship feature offered by Toolset and if that help you to simplify the things.
- https://toolset.com/course-lesson/what-are-post-relationships-and-how-they-work/
- https://toolset.com/course-lesson/how-to-set-up-post-relationships-in-wordpress/

If you do not want to go with post relationship then I will require problem URL and admin access details and a test case that on what post you want to display what information exactly. Please share what view you created and you added on what page/post.

*** 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 have set the next reply to private which means only you and I have access to it.

#2797252

Minesh
Supporter

Languages: English (English )

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

With your view:
=> hidden link

I checked that the custom field that holds the aid account id is "aid-account-id".

So instead of the code you were using as given under:

<li><strong>Account (New and Improved):</strong> [wpv-view name="display-current-aid-account" aidaccountid="[types field='account-id'][/types]"]</li>

I've changed the above code as given under:

<li><strong>Account (New and Improved):</strong> [wpv-view name="display-current-aid-account" aidaccountid="[types field='aid-account-id' output='raw'][/types]"]</li>

Where as you can see how I passed the "aidaccountid" value using he shortcode:

aidaccountid="[types field='aid-account-id' output='raw'][/types]"

Can you please confirm it works as expected now:
- hidden link

#2797253

That worked! Thanks Minesh, I really, really appreciate the help!