Skip Navigation

[Resolved] Custom Term Fields do not show on conditional shortcode drop down within Views

This support ticket is created 5 years, 11 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 13 replies, has 2 voices.

Last updated by Ben 5 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1158165

Ben

I am using Conditional Shortcodes within Views to try and display Custom Term Fields on an Archive page with conditional logic. I am finding that the drop down menu to select Types Fields only gives me the option to select from Custom Post Fields and not Custom Term Fields.

Is this expected? And is there another way to achieve what I want to do?

#1158610

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Yes - for now, I can see its expected thing that it only loads the custom post fields, not the term fields.

I'll take this as a new feature request and forward this to concern person.

The alternate solution would be you should try to add conditional statement manually.

More info:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#1158804

Ben

Thank you Minesh. I will have a look at the documentation.

#1158812

Ben

I've had a look at the documentation and I've tried to write this myself, but I'm not sure if I'm doing it correctly.

What I have written doesn't seem to be functioning as expecting and I'm getting the following debug information.

--------------------
Original expression: ( $(wpcf-test-custom-term) ne '' )
--------------------
--------------------
Converted expression: ( '' ne '' )
--------------------

Is this telling me that a custom term "wpcf-test-custom-term" doesn't exist? Because the term definitely exists on my installation.

Are Custom Term Fields definitely compatible with conditional logic? Or what am I doing wrong?

#1159408

Minesh
Supporter

Languages: English (English )

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

Hello Ben,

Could you please tell me where exactly you are trying to check the custom term field value using conditional statement? on custom post type Single page or on archive or within view? If its view - the view is set to display what content?

#1162069

Ben

Minesh, I am trying to check the custom term field using a conditional statement within a View that is placed on an Archive. The View is set to display the same taxonomy as the Archive where it is being displayed, there are no Query Filters or other settings active.

#1162688

Minesh
Supporter

Languages: English (English )

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

Could you please share edit page screenshot of your view, so I will review it and guide you in the right direction.

#1163079

Ben

Thank you Minesh. This View is being displayed on a Term Archive Template. The Content Selection is the Taxonomy that it is being displayed on, there is no Query Filter or any additional settings changed and I am using the below code in the Loop Editor.


[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
          [wpv-taxonomy-title]
		</wpv-loop>
[wpv-conditional if="( $(***CUSTOM TERM FIELD SLUG***) ne '' )"] Not Empty [/wpv-conditional]
[wpv-conditional if="( $(***CUSTOM TERM FIELD SLUG***) eq '' )"] Empty [/wpv-conditional] 
	<!-- wpv-loop-end -->
	[/wpv-items-found]
[wpv-layout-end]

If you need anything else, please let me know.

#1163775

Minesh
Supporter

Languages: English (English )

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

What if you try to use shortcode instead of the field slug:

For example:

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
        <wpv-loop>
          [wpv-taxonomy-title]
        </wpv-loop>
[wpv-conditional if="( '[types termmeta='your-field-name' output='raw'][/types]' ne '' )"] Not Empty [/wpv-conditional]
[wpv-conditional if="( '[types termmeta='your-field-name' output='raw'][/types]' eq '' )"] Empty [/wpv-conditional] 
    <!-- wpv-loop-end -->
    [/wpv-items-found]
[wpv-layout-end]
#1163890

Ben

I have tried that Minesh and it is still not working.

#1164619

Minesh
Supporter

Languages: English (English )

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

Well - again I created taxonomy archive page for my taxonomy "Student Types" and I've added the following code to loop output:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>        
		</wpv-loop>
	<!-- wpv-loop-end -->
[wpv-conditional if="( '[types termmeta='st-term-status'][/types]' eq '' )"]
empty
[/wpv-conditional]

[wpv-conditional if="( '[types termmeta='st-term-status'][/types]' eq '1' )"]
not empty
[/wpv-conditional]

[/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]

I'm checking the custom term field "st-term-status" for empty and not empty condition and I can confirm that it works just fine. So I'm not able to reproduce the issue you reported.

#1165038

Ben

I can't seem to see what is causing this my end.

Would you mind having a look at a staging site?

#1165353

Minesh
Supporter

Languages: English (English )

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

sure. Could you please send me access details and problem URL where you added the view.

*** 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.

#1165755

Ben

I have managed to solve the issue now Minesh.

All I needed to do was to select "Taxonomy is set by the page where this View is inserted" in the Query Filter and it all works how I wanted it to.

Thank you very much for your help.