[Resolved] Output Custom Fields conditionally from current post, inside a View
This thread is resolved. Here is a description of the problem and solution.
Problem: I have some conditional custom fields. If custom field A has option 1 selected, I want to display custom field B's value on the current post. If custom field A has option 2 selected, I want to display custom field C on the current post.
Solution: There's no need for a View since you're placing these shortcodes on the single post page. The Types and Views shortcodes will display information about the current post, by design. Move your conditionals into the Content Template.
This support ticket is created 6 years, 1 month 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.
I have set up a CPT of Countries and have attached three Custom Field Groups to it. I have two Custom Field Groups that are displayed conditionally dependant on the value of a Custom Field in the static CFG. Both of the conditional CFGs contain CFs that are URLs.
I want to be able to display the URLs of whichever CFG is displayed conditionally.
I was thinking there might be two ways to achieve this.
To have some sort of method where all the CFs from both conditional CFGs are displayed and hide the blank ones. I'm not sure there's a way of doing this with Toolset though?
Or using Views and creating three separate Views. One each to display the CFs from each conditional CFG. Then creating another one to hold both and using the conditional logic from within Views to display the View that is required. However, I cannot find a way from within Views to Query only the current CPT.
Is there a way to do this with Views? Or is it better to start somewhere else altogether?
Hello. Thank you for contacting the Toolset support.
Well - as I understand, you want to query specific post ID that belongs to specific post type? If Yes, yes, you can filter your view by specific post ID.
If this is not what you are looking for, I need more details about your requirement with few screenshots that will help mt to understand your issue and based on that information I will be able to guide you in right direction.
I don't believe that is what I am looking for. Let me try to explain better. I have included screenshots to help.
I have a Static CFG set up with a CF of "Type". This allows selection of either Type 1 or Type 2.
I then have other CFGs set up to display conditionally based on the selection of the Type CF from the Static CFG.
Using these, each post has an URL attached to it, either of Type 1 or Type 2 (dependant on the selection in the Static CFG).
I want to be able to design a View (or achieve it some other way) that I can use on a template for the post type, to display the URL that the post has attached to it.
Thanks for that Minesh. I was trying something similar with Views by myself but neither your version nor mine seem to work.
I used all the config from Post 1123610.
Screenshots attached so you can see the setups and outputs.
In both Test Type 1 and Test Type 2, both Views show both links 1 and 2 for each page, when I expected it to show Link 1 for Type 1 and Link 2 for Type 2.
No Minesh. Post 1123610 was in reference to the reply on here (please see attached).
I want to fetch the values from Test Type 1 and Test Type 2 as shown above in reply 1123819. In the same reply I mention two Views. One that I tried myself using Views conditional options, and another that you suggested. The output of these two Views is also shown there with my explanation of what I was expecting to see.
Well - it still give 403 page error for me and one of my colleague. I'm still here if you share working access details, if I will not get working access details in next reply, I will pass this ticket to another supporter as per your request.
I have set the next reply to private which means only you and I have access to it.
Minesh, I'm really not sure why you are getting a 403. Could you send us a screenshot of what you see and I can look into it? I can't see anything my side that could be causing a 403.
I have no idea why you or your colleague are seeing that.
Let me try and figure it out this end. In the meantime could you transfer the ticket another Supporter if possible? Someone ideally around GMT -04:00 or -05:00 would suit great. The only reason I request a change of Support is the timezone difference. Thank you for all your help with this. You have been brilliant!
Could you also please delete reply 1124600 or the Nimbus screenshot.
I see a 403 error when I go to /wp-admin, so I'm not able to log in. When I go to the root, I see a "Coming Soon" page with a large image of London, showing the London Bridge. Screenshot attached with URL obscured.