Hi,
I created two content views. One view is assigned to a custom type and the sidebar view is not assigned.
The assigned view is okay (at this time unformated), but the sidebar view widget is still empty. The sidebar view should display additional data to the shown post (view custom type).
I tried it with another theme, but the result is the same.
Thanks for help!
Hello, I'll be glad to take a closer look. A View must have something selected in the Content Selection panel, otherwise it will include no results. It sounds like you said "the sidebar view is not assigned", which I interpret as meaning you have chosen nothing in the Content Selection area of the View editor. If that is the case, I would not expect to see any results. If you want to see results, then you must select a custom post type, or Users, or a custom Taxonomy in the View editor screen when you edit the View.
Can you take some screenshots of the View editor screen when you edit the sidebar View? I would like to review your configurations to see what needs to be changed in this case so you will see results in the sidebar View. Please be sure to include screenshots showing all of the following information:
- Content Selection panel
- Query Filter panel
- Loop Editor panel
If you cannot see any of these panels in the View editor screen, scroll to the top right corner of the View editor screen and click "Screen Options". Activate the corresponding panel here in Screen Options to see it appear in the main View editor. Take screenshots of each panel and include those in your next reply.
Please also let me know where you want to be able to see this sidebar View. Do you want to see the View displayed in the sidebar of posts from more than one post type? If so, which post types, specifically?
Hi Christian,
hope you doing well and thank you for your answer, I appreciate it.
Unfortunately I have no screenshots, because I am not at my computer, but I try to explain it a little bit better.
I have a custom post type "job ads". There I have different taxonomies and custom fields.
The content view for "job ads" is working as expected. Now I try to show some of the custom fields from the current post of "job ads" in the sidebar. How can I do this?
Hope this helps 🙂
First, I should mention it is not necessary to use a View to display fields from the current post in a widget. For example, you can place a Custom HTML widget in the sidebar and use Types Fields shortcodes to display information from the current post. To display information from a Types field with the slug "book-number", you could insert this shortcode in a Custom HTML widget:
Book Number: [types field="book-number"][/types]
If you want more information about a shortcode-based approach, I can show you some information about using these Types field shortcodes for each type of custom field: https://toolset.com/documentation/customizing-sites-using-php/functions/
You can use Views shortcodes to display other post information, like the post title or post publish date. We have documentation for those shortcodes available in our programmer's documentation here: https://toolset.com/documentation/user-guides/views/views-shortcodes/
If you need to use a View for some specific reason, I recommend you do not use the WP Views Widget, because it is not possible to use a shortcode attribute with the WP Views Widget. In the situation you have described, you need to filter the View by post ID using the current post's ID. The best way to do that is to pass the current post's ID into the View's Query Filter using a shortcode attribute. In the legacy Views system your View shortcode would look something like this:
[wpv-view name="Your View Name or Slug" ids="[wpv-post-id item='$current_page']"]
You can see a nested shortcode that supplies the current post's ID to a shortcode attribute ids. You would apply a Query Filter in the View editor to filter by post ID set by a shortcode attribute ids and make sure the checkbox "Don't include current page in query result" is unchecked. See the screenshot for an example of this type of filter setup. However, as I said, when you place a View using a WP Views Widget, it is not possible to use a shortcode attribute so this technique will not work with the WP Views Widget. You must use a custom HTML widget instead.
Let me know if you have questions about this approach.
My issue is resolved now. Thank you!