Support

Account

Home Forums Front-end Issues Showing custom post type field on front-end with conditional logic

Solved

Showing custom post type field on front-end with conditional logic

  • Hey!

    I have created a custom single.php template. I have a Hello Elementor Child theme. In ACF I have a Field Group. I am showing some of these Field Group fields in single.php. Now I have a true/false field, which determines if the Register Form I have created with CF7 shows if that field is checked. (Right now the Register Form is shown through the WYSIWYG field via shortcode.)

    The problem is, that the condition works only in the backend. If I uncheck the condition, the field disappears in the backend, but still shows in the front-end.

    Any ideas on how to solve this? Does it have something to do with Hello-Elementor theme?

  • Conditional logic is only used in the admin when editing and has not effect on what is shown on the front end. You must code the front end to use it.

    example:

    
    if (get_field('true_false_field_name')) {
      // show the conditional field
    }
    

    This is not something you’re going to be able to do in elementor without creating custom code. More than likely you will need to code a custom shortcode and then use that shortcode in elementor.

  • Okay, thank you! That’s what I needed to know. Will use custom code for it!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.