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.
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.
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?
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?
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?
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":