Tell us what you are trying to do?
I have two Custom Post Types:
1. Mitarbeiter (Staff)
2. Klinik (Clinic)
I want a grid with all the "Mitarbeiter"s showing in which "Klinik" they work, like on the single post page here:
hidden link
"Klinik für Allgemein-, Viszeral- und Thoraxchirurgie" is the Klinik (Custom Post Type)
Is there any documentation that you are following?
I read up on several forum posts and internet searches.
Is there a similar example that we can see?
On another page I solved it with a Taxonomy called "Abteilung" but that had other drawbacks.
What is the link to your site?
hidden link
This is the page with alle "Mitarbeiter"s in a View Loop with a Content Template. Unfortunately, it says "No items found" on that page.
Hi,
Thank you for contacting us and I'd be happy to assist.
Can you please see if a relationship query filter has been added in the view's settings, as explained in the following guide:
https://toolset.com/lesson-placement/lesson-placements-1729031-1730449/
In case it still doesn't show the related posts, you're welcome to share temporary admin login details in reply to this message.
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
regards,
Waqar
Hi Harry,
Thank you for sharing the access details.
The view 'Kliniken Liste' was set with the 'Kliniken that are related to the current Mitarbeiter' option in the content selection settings, which was working for the case of a single 'Mitarbeiter' post page, but not in a wider context, when used from within another view, that was showing all the 'Mitarbeiter' posts.
I've changed that view's settings to 'All Kliniken' option and added a post-relationship query filter, below it, so that it brings the results related to the 'The current post in the loop'.
( screenshot attached )
After this change, this view is working for both cases.
I hope this helps and please let me know if you need further assistance.
regards,
Waqar
Hi Waqar,
awesome, thanks for your help. Another question: Is it possible to display the related "Kliniken" as a comma-separated list of links? Like this:
View Mitarbeiter of Klinik, Klinik für Anästhesie und Intensivmedizin, Palliativ- und Schmerzmedizin, Klinik für Allgemein-, Viszeral- und Thoraxchirurgie
Thanks
Harry
Glad I could help.
To make those post title links appear as a single-line text, you can include the following CSS code in the view's 'Custom CSS' field:
#wpv-view-layout-243-CPID330 .js-wpv-loop-wrapper * {
display: inline-block;
margin: 0px !important;
}
I was on vacation for a few days, I'll look into this asap. I also had another question, but can't remember right now -_-
Please take your time and mark this ticket as resolved once it is confirmed that the code works.
You're welcome to start a new ticket, whenever you have a new question or concern.
Thanks Waqar, I had to adapt the code to make it work:
.wpv-view-output [id^="wpv-view-layout-243-"] .js-wpv-loop-wrapper .wpv-block-loop-item, .wpv-view-output [id^="wpv-view-layout-243-"] .js-wpv-loop-wrapper .wpv-block-loop-item > div { /* .view-kliniken-liste */
display: inline;
}
.wpv-view-output [id^="wpv-view-layout-243-"] .js-wpv-loop-wrapper .wpv-block-loop-item:not(:last-child) a:after {
content: " | ";
}
.wpv-view-output [id^="wpv-view-layout-243-"] .js-wpv-loop-wrapper {
margin-bottom: 1em;
line-height: initial;
}
Is there a way to display a view without the search by adding an attribute to the shortcode? I couldn't find anything in the documentation here https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view
E.g. something like this:
[wpv-view name="My amazing custom post list" search="nope"]
Thanks for writing back and for sharing the code reference. It will prove useful for other users, with a similar requirement.
Yes, it is possible to pass values to views using the shortcode attributes, when calling them through the shortcode 'wpv-view'.
Here is a useful guide on the topic:
https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/
This guide specifically covers the classic/legacy views, but the same logic should also work with the blocks-based views filters too. It is important to note however, that the 'Views' block doesn't support accepting attributes, so even if you've created a view using the blocks editor, you'll have to call it on a page/post through the views shortcode 'wpv-view', in order to pass some attributes.
Thanks for the guide. It can't be used to hide the search because it's outside of the loop but I could solve it with some simple CSS.
You may close the ticket, thank you!
Thanks for the update and I'm going to mark this ticket as resolved.
You're welcome to start a new ticket, for each new question or concern.