Skip Navigation

[Resolved] Filter view by entries in custom post

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 6 replies, has 2 voices.

Last updated by Minesh 1 year, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2625053

Bob

I have a custom post - Books this has a unique ID for each book.
A second type - Loaned this may have several entries for a single book and has the ID in a field

What I want to do is display all books that have not been loaned, e.g. are not in the Loaned post type.

I can do this is MySQL but would like to run it as a Toolset View if at all possible.

Thanks in advance

#2625201

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please share admin access details I will have to review your current setup and then I will be able go guide you in the right direction.

Also, Please share details on what page you want to display the book posts that are not loaned.

*** 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.

#2626627

Minesh
Supporter

Languages: English (English )

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

I do not see any Books post type when I login to the admin. Are you referring to any other post type? Where with what post type I can see the unique field you are talking about?

#2626673

Bob

Apologies Minesh I did not explain that well.

The results I need are all posts in type Items where the post ID IS NOT in (all the values in the post type Loans for the field Loan Member)

So the SQL would be
SELECT `post_title` FROM `psr_posts` where `post_type`="item" and `ID` not in (
SELECT `meta_value` FROM `psr_postmeta` where `meta_key` = "wpcf-loan-member")

Is there I way I can replicate that in Toolset or indeed use by SQL?

#2626681

Minesh
Supporter

Languages: English (English )

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

Ok that you for that details. Can you please tell me what is the view you created to display the Items post type posts and to what page you added that view?

#2626689

Bob

I haven't created the view yet, that's what I'm not sure how to do. I can create the page once the view is working I assume?

#2626705

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've created the following view, the following view is used to fetch/get all the Load member IDs from the "Loan" post type
- hidden link

The above view is set to display comma separated "list-with-separators" output:
- https://toolset.com/documentation/legacy-features/views-plugin/view-layouts-101/#list-with-separators

Then I've created the following view to display the posts of "Item" post type:
- hidden link
Where:
- I've added the post ID query filter to "Query Filter" section:

Exclude posts with IDs set by the View shortcode attribute "ids" eg. [wpv-view name="view-name" ids="1"]

- We set the above view to filter with shortcode attribute "ids":

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes

Then I've added the view to the following page where I've added the "Fields and Text" block and added the view:
- hidden link

[wpv-view name="show-items-excluding-loan-member-ids" ids="[wpv-view name='get-all-loan-member-ids']"]

Can you please confirm it works as expected now.

#2626721

Bob

As ever excellent support