Tell us what you are trying to do?
I have the following code in a view that is part of a wider set of code that displays a list of custom post titles then next to each one, a taxonomy term. There are two terms (is that the right word for them) in the list, *New* and *Featured*. I wish to only show the taxonomy if it is *New*, so how can I write what I think is a conditional something or other to say ‘if this post has a tick for the *New* taxonomy item, then put it here, or don’t put anything?
<wpv-loop>
[wpv-post-link]
[wpv-item index=other]<font style='color:#fc92dc'>[wpv-post-taxonomy type="girl-promotion" format="name"]</font> <font style='color:#000000'>-</font>
[wpv-item index=last]<font style='color:#fc92dc'>[wpv-post-taxonomy type="girl-promotion" format="name"]</font> <font style='color:#000000'></font>
</wpv-loop>
Many thanks,
Barry.
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site? hidden link The view in question is the horizontal list of girl's names in the footer.
I wish to only show the taxonomy if it is *New*, so how can I write what I think is a conditional something or other to say ‘if this post has a tick for the *New* taxonomy item, then put it here, or don’t put anything?
Hi, there's not an easy way to do this with the wpv-post-taxonomy shortcode because it's not highly configurable. Instead, you would create a new View of this taxonomy and add a filter by term, where the term is set by the current post. Eventually you will nest this View in the View of custom posts to make it dynamic. In the loop of this View of taxonomy terms, you will add conditional HTML that tests the current term. If it matches the "new" term, display the term or term archive link or whatever. If not, display nothing.
If you need more information about the conditional part, we have documentation available here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
Let me know if this doesn't make sense and I can try to offer some additional guidance.
Hi Christian,
I've tried to do this without further help but I'm stuck. I think I understand what you mean but I also think I'm missing something. I've added the following conditional within the view (a new one I've created from scratch) and to me the original view query correctly finds all girls with another taxonomy ticked called 'onsite'. So that works as the girls names are listed. The conditional, added just after the post name (where I want the term to show), says ' find the custom posts with the taxonomy 'Girl Promotions with term *New* but it doesn't to me say, if you find them, show the text *New* and if the post doesn't have *New* as a term, then show nothing. So I think I'm missing that last bit. Am I getting there? If you can nudge me in the right direction or tell me what I need to do I'd be grateful.
I do understand that rather than show the term itself automatically, I might need to physically write the term out in text in the conditional.
<wpv-loop>
[wpv-item index=other]
<font style="color:#000000;">[wpv-post-title][wpv-conditional if="( CONTAINS(#(girl-promotion),'*New*') )"], </font>
[wpv-item index=last]
<font style="color:#000000;">[wpv-post-title]</font>
</wpv-loop>
(I've left out index-last for now).
Many thanks,
Barry.
I'm thinking something like this for the conditional:
[wpv-conditional if="('[wpv-taxonomy-title]' eq 'New')"]
New
[/wpv-conditional]
Does that make sense in your case? The wpv-taxonomy-title shortcode is used to represent the name of the current term in the loop.
Hi Christian,
Thank you for your help but perhaps this is something that can't be done. I don't want to waste any more of your time so I've removed the view for now and I'll try to revisit the idea if I can later on. I'm very grateful for you trying though. Many thanks,
Barry.
I'm sure it can be done, and you're definitely not wasting my time. I'm here to help, and I'm sorry this is discouraging. I don't want to give up. If you'd like, I can log in to the site, take a closer look, and set things up for you in a test area. Then we can review the changes I made before you add them to the live area. If you'd like to collaborate, please provide admin login credentials in the private reply fields here in the forum.
Okay please take a look at this new View I created:
hidden link
This is a View of the 'Girl Promotion' taxonomy, filtered by term, where the term is set by the current post in the loop. This means if I insert this View in another View of posts, only the terms associated with the current post in the loop will be displayed.
In the Loop of this View, I added the conditional to display only the term "*New*". This means that even if other terms from this taxonomy are associated with the current post, they will not be displayed.
Next, I removed the conditional content from your original list View and inserted the new View instead:
hidden link
This technique of nesting views is useful when you want to make lists within lists...in this case lists of terms in lists of posts.
Let me know if you have additional questions about that.
Hi Christian,
That's truly brilliant. I'm going to have to study what you did carefully until I understand it fully but it's absolutely perfect so thank you very much for all the effort.
Many thanks,
Barry.
My issue is resolved now. Thank you!
Excellent, feel free to reach out here in the forums anytime you get stuck.