How can I create a conditional for an "archived" listing to only display if the status is "archived" and an admin is viewing the listing?
Hello, are you talking about hiding the posts in the results of a View or hiding the single listing posts? I'm not quite clear, because you mentioned Query Filters, Content Templates and viewing the listing. Query Filters are used in a View to hide certain results based on specific filter criteria. However, you also mentioned Content Templates and viewing the listing, which usually are related to the single posts on your site. Let's discuss both.
Let's assume you need to display the results of a Toolset View based on two conditional criteria. One part is based on user role, and the other part is based on the taxonomy term(s) assigned to the post. In Views (or Blocks) unfortunately there are no Query filters available that correspond to the current User or the current User's role. Instead, you can use toolset_access shortcodes in the View's loop editor to display post content conditionally based on User role. In the following example, only Administrators will see the post title:
[toolset_access role="Administrator" operator="allow"]
[wpv-post-title]
[/toolset_access]
We have documentation available here for configuring these shortcodes: https://toolset.com/documentation/user-guides/access-control/access-control-texts-inside-page-content/
Feel free to let me know if this doesn't make sense, or if you need help implementing Access shortcodes.
The second part of the conditional display depends on the term or terms assigned to the post, and this filtering can be accomplished by adding a Query Filter to the View. If you cannot see the Query Filter panel when you edit the View, scroll to the top right corner and click "Screen Options". You can activate the Query Filter panel here. Now you will add a new filter based on the status taxonomy, where the term assigned is any of the following, then choose the archived term.
The combination of this term Query Filter and Access shortcodes will help hide the results of a View depending on the two conditional criteria: status taxonomy term, and current User role.
Now let's assume you need to stop a non-admin User from seeing archived single Listing post if they click an archived listing link on Google or type the URL directly into their browser. If you want to hide the content from the single Listing post, you must add conditional HTML or a conditional block in the single Listing Content Template. This is where your conditional comes into play. You could use this conditional in the Content Template to show specific content for the archived posts.
[wpv-conditional if="( CONTAINS(#(status),'archived') )"]
This content is archived!
[/wpv-conditional]
Or, you could wrap the entire contents of the template in a conditional that tests if the term "archived" is NOT associated with the post:
[wpv-conditional if="( CONTAINS(#(status),'archived') )" evaluate="false"]
This content is not archived!
[/wpv-conditional]
If the term is associated with the post, then nothing will be displayed here.
Please let me know if you have questions about this.