Problem: I would like to show a list of links to posts that is filtered by two custom fields representing the current User ID and the current post ID.
Solution: - Create a View of Library Articles with no filters
- In the Loop Output of the View, insert a post link shortcode.
- Use the wpv-post-field shortcode to set the post link "item" attribute. This will allow you to display the post link of another post, using the custom field value.
[wpv-post-link item="[wpv-post-field name='wpcf-current-post-id']"]
Replace current-post-id with the slug of your current post ID field from wp-admin. Be sure to keep the wpcf- prefix here, it's required.
You also mentioned that there is a current User ID field on the Library Article post. If you want to filter this list by the current User's ID (like a "My Library" list), go back to the View and add a custom field filter based on the user ID field. Choose the option "set by one shortcode attribute", and make that attribute something like "userid". Now in your View's shortcode, you can pass the current User's ID into the filter using the shortcode attribute. So the View shortcode would look something like this:
[wpv-view name="your-library-article-view" userid="[wpv-user field='ID']"]
Relevant Documentation:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/
https://toolset.com/documentation/user-guides/views-shortcodes/
https://toolset.com/documentation/customizing-sites-using-php/functions/
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 6 months ago.
Assisted by: Christian Cox.