Skip Navigation

[Resolved] Conditional display based on parent post

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

Problem: I would like to use conditional HTML to display some content based on whether or not the current User has created a post in some other custom post type.

Solution: You can use a View's built-in results found conditional to do this.

  • Create a View of Author posts, and apply any filters necessary to show the Author post related to the current profile.
  • In the Loop Output editor, include the new Book, Post, and other CRED form links just outside the wpv-loop tag, so that if any Author post is found, these CRED links will be displayed.
  • Instead of the "No items found" message, insert your New Author CRED form link. This means that no Author posts exists, so they need to create one. Example below:
  • [wpv-layout-start]
        [wpv-items-found]
        <!-- wpv-loop-start -->
         Link to book form
             Link to poster form
             ... etc...
              <wpv-loop></wpv-loop>
        <!-- wpv-loop-end -->
        [/wpv-items-found]
        [wpv-no-items-found]
            Link to author form
        [/wpv-no-items-found]
    [wpv-layout-end]
    
    This support ticket is created 7 years 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
    8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
    13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

    Supporter timezone: America/New_York (GMT-04:00)

    This topic contains 2 replies, has 2 voices.

    Last updated by toolset-dave 7 years ago.

    Assisted by: Christian Cox.

    Author
    Posts
    #587698

    Hi,

    I have a profile page which has links to forms for creating child posts (lets say books, posters, paints) and one for the form for creating parent post (author). I would like to make a conditional display for links to child forms. They would show only if there is at least one (non specified author) parent post, which is in published state.

    #587764

    Hi, you could use a filtered View's items-found and no-items-found to accomplish this.
    - Create a View of Author posts, and apply any filters necessary to show the Author post related to the current profile.
    - In the Loop Output editor, include the new Book, Post, and other CRED form links just outside the wpv-loop tag, so that if any Author post is found, these CRED links will be displayed.
    - Instead of the "No items found" message, insert your New Author CRED form link. This means that no Author posts exists, so they need to create one. Example below:

    [wpv-layout-start]
    	[wpv-items-found]
    	<!-- wpv-loop-start -->
    	 Link to book form
             Link to poster form
             ... etc...
              <wpv-loop></wpv-loop>
    	<!-- wpv-loop-end -->
    	[/wpv-items-found]
    	[wpv-no-items-found]
    		Link to author form
    	[/wpv-no-items-found]
    [wpv-layout-end]
    
    #589234

    Hi, thanks for help.