PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Conditional Logic in Post Template?

  1. I'm working on setting up a new form that uses the Post fields to allow people to submit draft posts to a site. I love the idea of being able to create the post template using merge tags, but have one question:

    Is there any way to set up any kind of conditionals within that template?

    For instance, I am collecting a URL and a featured image in the form, but neither of those fields are required. If the user does not include those items, is there any way to leave them out of the Post Template? I'm not sure I can use them if there's no way to set up conditions for that post template. Otherwise, I'll end up with a lot of posts that include things like <img src="" alt=""/> or <a href="">Foo</a>, where the HTML values are blank because the information wasn't submitted with the form.

    It would be nice if there was a way to say something like:
    If URL and image are both filled in, use post template a
    If URL is not blank, use post template b
    If image is not blank, use post template c
    If image and URL are blank, use post template d


    Posted 9 years ago on Friday May 3, 2013 | Permalink
  2. David Peralty

    As far as I know, this currently doesn't exist.

    Most people that want to do things like this use WordPress custom fields in their forms so that they can do a test in their theme using PHP to see if the custom field has a value and then do what they need.

    I will move this to feature requests though so our developers see it.

    Posted 9 years ago on Friday May 3, 2013 | Permalink