Tell us what you are trying to do?
I need to get conditional data from two views. I understand that views cannot be nested so I'm looking for a work around.
I have two relevant CPT's Agents and properties
I have a my account page which displays user info, agent info and property info.
I have two views on the page, the first (search for agents matching logged in user) I use conditional based on 'Number of items found in views' = 0 to display create agent button.
In the second view (search for properties matching logged in user), I want to use another conditional so 'Number of items found in views' =0 to display create property button. The problem is I need this button to only show if an agent has been created first. I can't add a conditional in the property view that relates to the agent view so I need to a way to work around this?
I'm not sure I understand fully the display condition of the Create property button. Is it that when there is an agent you want to display the create property button ?
If such is the case the view itself should already meet that condition for you. For instance if you're displaying the agents with the view then within the [wpv-items-found] shortcode you can add the create agent button as this section will only display if there are agents.
So for the property button to show if these conditions must be met -
Number of items found in property views' = 0
Number of items found in agent views' > 0
So you're able to do the Add Property button successfully based on the Number of items found in property views' = 0 condition.
However the issue is with the Number of items found in agent views' > 0 condition?
Is the Agent view a part of the property view search ? Perhaps sending me an example will help a bit. I'm thinking that you can add the button in the Agent view within the wpv-items-found shortcode because the contents of this shortcode will only display when the view returns at least 1 result.
Hi Shane,
Yeah that's correct. So I've got 2 views, one for agent and one for property but I need to access conditions from both but they cannot be nested (view in a view)? I want to have the create new property button appear in the property view before the loop content. The create new agent button isn't an issue because the conditional for that button only applies to agent view whereas the property button condition applies to both agent and property view.
Show property button if
Number of items found in property views' = 0 condition AND agent views' > 0 condition.
I hope this makes sense. Thank you!