Tell us what you are trying to do?
I have a View Loop for a CPT "Entries" - If an author viewing the loop has not made a post using a certain Custom Taxonomy I would like to display some HTML.
I am trying not to create multiple views - one for each Taxonomy Month (see below).
====
Example:
====
CPT Name - Entries
Taxonomy - Months (January, February, March, April, May, June....)
If in a view a user (Author) does not have an entry for "March" then I want to display HTML "Remember to enter for March" plus a link to the registration form
====
Possible?
Hi,
Thank you for contacting us and I'd be happy to assist.
This is possible using a single view, and here are the steps that I'll recommend:
1. You can create a new page that will only be used to create a new view for the CPT "Entries".
2. In the view's query filter, you'll include two filters:
A. Post author filter to show posts from only the currently logged-in user.
B. Taxonomy filter where target term's name in one of those set by the View shortcode attribute 'wpvlistingsmonth'.
( example screenshot attached: query-filter-example.png )
3. In the 'No Items Found Text' field in the 'View Loop' block, you can include your message and for making the taxonomy term name (month) dynamic, you can use the 'wpv-attribute' shortcode:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-attribute
( example screenshot attached: no-items-found-message.png )
Remember to enter for [wpv-attribute name="wpvlistingsmonth"]
4. The last step would be to include this view for each month on the actual page, using the view's shortcode in a "Fields and Text" block:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view
Example:
[wpv-view name="Name of the view" wpvlistingsmonth="January"]
[wpv-view name="Name of the view" wpvlistingsmonth="February"]
[wpv-view name="Name of the view" wpvlistingsmonth="March"]
..............
Note: you'll change the 'Name of the view' with your actual view's name.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Hey! I appreciate the help - have this working or my needs now with one exception - I am trying to have different HTML for the no items found from month to month.
So for example March may read:
<img src="(march's banner image URL)">
Remember to sign up for March's Competition.
[march-form-shortcode]
**Also may want some month-specific html for march**
Then April may read:
<img src="(april's banner image URL)">
Remember to sign up for April's Competition.
[april-form-shortcode]
**Also may want some month-specific html for april**
Any suggestions?
Thanks for the update and glad that it worked.
To have more control over the 'no items found' text for each month, you can create a content template 'CT for no items found message'.
Inside this content template, you can add a "Fields and Text" block, and in the HTML tab, include the conditional content section for each month like this:
( ref: https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/ )
[wpv-conditional if="( '[wpv-attribute name="wpvlistingsmonth"]' eq 'January' )"]
This is the message for January
[/wpv-conditional]
[wpv-conditional if="( '[wpv-attribute name="wpvlistingsmonth"]' eq 'February' )"]
This is the message for February
[/wpv-conditional]
[wpv-conditional if="( '[wpv-attribute name="wpvlistingsmonth"]' eq 'March' )"]
This is the message for March
[/wpv-conditional]
..............
After the content template is ready, you can include its shortcode in the 'No Items Found Text' field of the view ( mentioned in step 3 of my last message):
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body )
[wpv-post-body view_template="CT for no items found message"]