Skip Navigation

[Resolved] Term custom fields not available for conditional tests

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to display content conditionally on taxonomy term archive based on term custom field

Solution:
You can use [wpv-conditional] to check the term custom field value on term archive page.

For example:

[wpv-conditional if="( '[types termmeta='module-partner-logo' output='raw' term_id='[wpv-taxonomy-archive info='id']'][/types]' ne '' )"]
  
Your code goes here
 
[/wpv-conditional]

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/term-custom-fields-not-available-for-conditional-tests/#post-1101613

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by davidR-12 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1100544

I have a page here:

hidden link

password: Europa-808

This is an archive view displaying a taxonomy term. However in the loop editor, I dont have any access to the custom fields I have created for this taxonomy when using conditional tests.

I want to hide the black 'Sponsored by' section of there is no logo (As there is not in the above link). the logo is an image custom fields assigned to this taxonomy.

The code for thi spage is:

[wpv-layout-start]
	[wpv-items-found]
<div class="container-fluid">
<div class="row justify-content-center module-main-top">
<div class="col-sm-9 ">
  <h1>Teach students about <span style="color:[types termmeta='module-colour'][/types];">[taxonomy]</span></h1>
  <p>[types termmeta='module-main-text'][/types]</p>
</div>
  </div>
  
  

<div class="row module-main-two-columns">
<div class="col-sm-6 module-main-left">
  <div class="module-main-left-inner">
  <p class="module-main-grey-text">Introduction</p>
    <h2>What is <span style="color:[types termmeta='module-colour'][/types];">[taxonomy]</span>?</h2>
  <p>[types termmeta='module-introduction-text'][/types]

  </div>
  </div>
<div class="col-sm-6 module-main-right">
  
   <div class="module-main-right-inner">
       <p class="module-main-grey-text">Sponsored by</p>
<img src="[types termmeta='module-partner-logo' output='raw'][/types]"><br/>
     <quote class="module-main-right-quote">[types termmeta='module-partner-quote'][/types]</quote>
<p class="module-main-right-cite">[types termmeta='module-partner-name'][/types]</p>
</div>
</div>
  </div>

  
  
<div class="row module-resource-title">
  <div class="col-sm-12">
    <h2><span style="color:[types termmeta='module-colour'][/types];">[taxonomy]</span> resources</h2>
</div>
  </div>

	<!-- wpv-loop-start -->
	<div class="wpv-loop js-wpv-loop">
	<wpv-loop wrap="4" pad="true">
		[wpv-item index=1]
		<div class="row ">
			<div class="col-md-6 col-lg-3 search-resource-single-main">[wpv-post-body view_template="Loop item in Archive for Module Categories"]</div>
		[wpv-item index=2]
			<div class="col-md-6 col-lg-3 search-resource-single-main">[wpv-post-body view_template="Loop item in Archive for Module Categories"]</div>
		[wpv-item index=3]
			<div class="col-md-6 col-lg-3 search-resource-single-main">[wpv-post-body view_template="Loop item in Archive for Module Categories"]</div>
		[wpv-item index=4]
			<div class="col-md-6 col-lg-3 search-resource-single-main">[wpv-post-body view_template="Loop item in Archive for Module Categories"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-md-6 col-lg-3 search-resource-single-main"></div>
		[wpv-item index=pad-last]
			<div class="col-md-6 col-lg-3 search-resource-single-main"></div>
		</div>
	</wpv-loop>

	<!-- wpv-loop-end -->
  
<div class="row">
    <div class="col-sm-12 module-download-all">
[purchase_collection taxonomy='download_category' terms='[taxonomy]' text='Add all to downloads' style='button' color='blue' class='buy-all-button']
  </div>
  	</div>
  
</div>
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

Regards,

David

#1100648

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - can I have access details so I can check your archive code and try to fix the issue.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#1101613

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you can use following conditional shortcode to check if your currently displayed taxonomy archive term has custom field image logo uploaded or not.

[wpv-conditional if="( '[types termmeta='module-partner-logo' output='raw' term_id='[wpv-taxonomy-archive info='id']'][/types]' ne '' )"]
 
Your code goes here

[/wpv-conditional]

Just wrap the code which you don't want to display when module-partner-logo is not exists.

#1101793

Hi Minesh,

That worked great thank you.

Regards,

David

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.