I have 2 blocks in a archive template that needs to be either displayed or hidden depending on the archive taxonomy that is open. The reasoning is that some of the CPT information only has 2 fields that needs to be filled vs alot more fields for posts linked to another taxonomy which warrants a single page view to be opened.
Conditional 1:
Taxonomy example - "Current Formal Quotations " - Has lots of information that has a click through button called "VIEW" to the single page view for the CPT - hidden link
Conditional 2:
Taxonomy example - "Financial Reports " - Only displays a title and link called "DOWNLOAD" on the archive page to the PDF file that is opened in new window. - hidden link
Currently "Condtional 2" is working and displaying the correct block with download button on on the correct category "Financial Reports"
Conditional 1 is not showing and dependant on conditional I played with displayes the "Download" button as appose to the "View" button.
Hello,
In the WordPress Taxonomy Archive page, you can get the current term's information with shortcode [wpv-taxonomy-archive], for example, below shortcode can output the term's slug:
[wpv-taxonomy-archive info="slug"]
You can use above shortcode as conditional shortcode's condition, check the shortcode value, then output something you want.
See our document:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-taxonomy-archive
https://toolset.com/course-lesson/using-toolset-conditional-block/#checking-for-shortcodes-values
Thank you, so am i to place the short code in the static value field as per attached screenshot of conditional which will then display the block and show relevant information?
I added the short code to verify the taxonomy term, but now both the "view" and "download" blocks are duplicating and showing for both terms where it is suppose to only display for only the one or the other dependent on category that post belongs to. See attached
Thanks, but now both blocks are displaying the "View" button" where only the one category is suppose to display the "view" button and the other category the "download" button
Thanks, but now both blocks are displaying the "View" button" where only the one category is suppose to display the view button and the other category the download button
You can try these:
In your screenshot:
https://toolset.com/wp-content/uploads/2021/09/2161851-Screenshot_2021_09_06_at_10.54.52.png
1) Click "Advanced Editor"
2) setup the condition like this:
( ( '[wpv-post-field name="taxonomy-archive" ]' eq 'specific-term-slug' ) )
See my screenshot ae.JPG
I have done this previously, but still the same result? It now actually doesn't display at all anymore.
Please share your website credentials in below private message box, also point out the problem archive page URLs, I need a live website to test and debug
Thanks for the details, in your case, I suggest you use has_term to check each single post has specific terms, then display different "View" and "Download" button for each post.
I have done below modifications in your website:
1) Dashboard-> Toolset-> Settings-> Front-end Content
hidden link
in section "Functions inside conditional evaluations", add the WP function name: has_term
2) Edit the WordPress Archive :
hidden link
Within the loop, setup two conditional block,
- the first conditional block, setup the condition as below:
( ( has_term('valuation-documents', 'george-doc-categories', null) eq '1' ) )
And display the "DOWNLOAD" button, you will need to customize the content manually
- the second conditional block, setup the condition as below:
( ( has_term('current-formal-quotations', 'george-doc-categories', null) eq '1' ) )
And display the "View" button, same as above you will need to customize the content manually
Test them in frontend:
hidden link
hidden link
I can see different buttons in each archive page.
Please test again, check if it is what you want. thanks
More help:
https://developer.wordpress.org/reference/functions/has_term/
Thank you, that is exactly what I wanted. If I wanted to add more categries to the conditional, would I just add it as a "," separated value in the below?
( ( has_term('valuation-documents', 'george-doc-categories', null) eq '1' ) )
I did notice though that my "view" links are not actually redirecting to the single page view, but rather returning to the archive page.
Q1) I have changed the second conditional block content as below:
...
<a class="dwnload" title="download" href="[wpv-post-url]" target="blank" rel="noopener">VIEW</a> [wpv-post-title]
...
The [wpv-post-url] shortcode will output the post URL directly, see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-url
Q2) If you want to check current post has one specific term, please try to setup the condition like this:
( ( has_term('MY-SPECIFIC-TERM-SLUG', 'george-doc-categories', null) eq '1' ) )
You need to replace the "MY-SPECIFIC-TERM-SLUG" with the specific term's slug
If you want to check current post has two specific terms, you can try like this:
( ( has_term('MY-SPECIFIC-TERM-SLUG-1', 'george-doc-categories', null) eq '1' ) AND ( has_term('MY-SPECIFIC-TERM-SLUG-2', 'george-doc-categories', null) eq '1' ) )
You need to replace the "MY-SPECIFIC-TERM-SLUG-1" and "MY-SPECIFIC-TERM-SLUG-2" with the specific term slugs
See documents:
https://developer.wordpress.org/reference/functions/has_term/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional
Thank you, i tried adding multiple terms as per attached screenshot. It however is not displaying the condition blocks for the the added term in link below.
hidden link
Is it possible to use a parent term and all child terms will show in the below condition:
( ( has_term('MY-SPECIFIC-TERM-SLUG', 'george-doc-categories', null) eq '1' ) )
I don't see any attached screenshot in your post:
https://toolset.com/forums/topic/conditional-display-of-two-blocks-in-archives/#post-2163565
For the new question:
Is it possible to use a parent term and all child terms will show in the below condition:
Please elaborate the question with more details, what "parent term and all child terms" do you want to check?
Regarding original question, beowis the term that is not displaying any information even though I updated the 2nd block conditional to include the term:
hidden link
Regarding the new question, I would ideally like to have the parent term "Supply Chain Management" and all child terms display post information as per the relevant archive block when the public browses any of these terms. At present if I insert the parent the term, the child terms do not display.
The child terms link are below that is suppose to display post listing after I inserted the parent term.
hidden link
hidden link